registerForm.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <view class="container">
  3. <u-cell-group class="form-info" :border="false">
  4. <u-field label="商家名称" placeholder="请输入商家名称" label-width="180" v-model="shopInfo.name" disabled></u-field>
  5. <u-cell-item title="请上传商家图标" :arrow="false">
  6. <view slot="label">
  7. <u-upload :action="uploadUrl" :file-list="defaultList1" :form-data="uploadData" @on-success="logoUploadSuccess"
  8. @on-error="uploadError" max-count="1"></u-upload>
  9. </view>
  10. </u-cell-item>
  11. <u-cell-item :title="'请上传店铺主图(' + fileList.length + '/3)'" :arrow="false">
  12. <view slot="label">
  13. <u-upload :action="uploadUrl" :file-list="defaultList2" :form-data="uploadData" @on-success="uploadSuccess"
  14. @on-error="uploadError" @on-remove="uploadRemove" max-count="3"></u-upload>
  15. </view>
  16. </u-cell-item>
  17. <u-cell-item title="请上传身份证正反面" :arrow="false">
  18. <view slot="label" class="id-card-box">
  19. <image class="id-card" :src="shopInfo.idCardCopyFilePath"></image>
  20. <image class="id-card" :src="shopInfo.idCardNationalFilePath"></image>
  21. </view>
  22. </u-cell-item>
  23. <u-cell-item title="请上传营业执照照片" :arrow="false">
  24. <view slot="label" class="license-box">
  25. <image class="license-img" :src="shopInfo.businessLicenseCopyFilePath"></image>
  26. </view>
  27. </u-cell-item>
  28. <u-field label="法人姓名" placeholder="请输入法人姓名" label-width="180" v-model="shopInfo.duty" disabled></u-field>
  29. <u-cell-item title="所在城市" @click="regionShow = true">
  30. <text v-show="shopInfo.companyAddressProvince">{{shopInfo.companyAddressProvince}}-{{shopInfo.companyAddressCity}}-{{shopInfo.companyAddressDistrict}}</text>
  31. </u-cell-item>
  32. <u-field label="联系方式" placeholder="请输入联系方式" label-width="180" v-model="shopInfo.contactTel"></u-field>
  33. <u-field label="收款人姓名" placeholder="请输入收款人姓名" label-width="180" v-model="shopInfo.collectionName" disabled></u-field>
  34. <u-field label="户名" placeholder="请输入户名" label-width="180" v-model="shopInfo.bankAccountName" disabled></u-field>
  35. <u-field label="银行名称" placeholder="请输入银行名称" label-width="180" v-model="shopInfo.bankAllName" disabled></u-field>
  36. <u-field label="银行卡号" placeholder="请输入银行卡号" label-width="180" v-model="shopInfo.bankNumber" disabled></u-field>
  37. </u-cell-group>
  38. <view class="form-handle">
  39. <u-button type="success" shape="circle" :ripple="true" @click="edit = true" class="handle-custom" v-if="!edit">编辑</u-button>
  40. <u-button type="success" shape="circle" :ripple="true" @click="submitData" class="handle-custom" v-else>提交</u-button>
  41. </view>
  42. <u-picker mode="region" v-model="regionShow" @confirm="setRegion"></u-picker>
  43. <u-top-tips ref="uTips"></u-top-tips>
  44. </view>
  45. </template>
  46. <script>
  47. const NET = require('@/utils/request')
  48. const API = require('@/config/api')
  49. export default {
  50. data() {
  51. return {
  52. edit: false,
  53. shopInfo: {
  54. name: '',
  55. logo: '',
  56. idCardCopyFilePath: '',
  57. idCardNationalFilePath: '',
  58. businessLicenseCopyFilePath: '',
  59. duty: '',
  60. companyAddressProvince: '',
  61. companyAddressCity: '',
  62. companyAddressDistrict: '',
  63. contactTel: '',
  64. collectionName: '',
  65. bankAccountName: '',
  66. bankAllName: '',
  67. bankNumber: '',
  68. },
  69. regionShow: false,
  70. uploadData: {
  71. folderId: 0,
  72. },
  73. uploadUrl: '',
  74. fileList: [],
  75. defaultList1: [],
  76. defaultList2: [],
  77. }
  78. },
  79. onLoad(options) {
  80. this.uploadUrl = API.uploadFile
  81. NET.request(API.getShopRegisterInfo, {}, 'GET').then(res => {
  82. this.shopInfo = {
  83. name: res.data.name,
  84. logo: res.data.logo,
  85. idCardCopyFilePath: res.data.idCardCopyFilePath,
  86. idCardNationalFilePath: res.data.idCardNationalFilePath,
  87. businessLicenseCopyFilePath: res.data.businessLicenseCopyFilePath,
  88. duty: res.data.duty,
  89. companyAddressProvince: res.data.companyAddressProvince,
  90. companyAddressCity: res.data.companyAddressCity,
  91. companyAddressDistrict: res.data.companyAddressDistrict,
  92. contactTel: res.data.contactTel,
  93. collectionName: res.data.collectionName,
  94. bankAccountName: res.data.bankAccountName,
  95. bankAllName: res.data.bankAllName,
  96. bankNumber: res.data.bankNumber,
  97. }
  98. this.fileList = res.data.storeImgUrl.split(',')
  99. this.defaultList1 = [{
  100. url: res.data.logo
  101. }]
  102. this.defaultList2 = res.data.storeImgUrl.split(',').map(site => {
  103. return {
  104. url: site
  105. }
  106. })
  107. }).catch(res => {
  108. this.$refs.uTips.show({
  109. title: '获取注册信息失败',
  110. type: 'warning',
  111. })
  112. })
  113. },
  114. methods: {
  115. // logo上传成功回调
  116. logoUploadSuccess(res, index, lists, name) {
  117. this.shopInfo.logo = res.data.url
  118. this.$refs.uTips.show({
  119. title: 'logo上传成功',
  120. type: 'success',
  121. })
  122. return true
  123. },
  124. // 文件上传成功回调
  125. uploadSuccess(res, index, lists, name) {
  126. this.fileList.push(res.data.url)
  127. this.$refs.uTips.show({
  128. title: '文件上传成功',
  129. type: 'success',
  130. })
  131. return true
  132. },
  133. // 文件上传失败回调
  134. uploadError(res, index, lists, name) {
  135. this.$refs.uTips.show({
  136. title: '文件上传失败',
  137. type: 'warning',
  138. })
  139. },
  140. // 移除文件回调
  141. uploadRemove(index, lists, name) {
  142. this.fileList.splice(index, 1)
  143. },
  144. // 设置地址
  145. setRegion(data) {
  146. this.shopInfo.companyAddressProvince = data.province.label
  147. this.shopInfo.companyAddressCity = data.city.label
  148. this.shopInfo.companyAddressDistrict = data.area.label
  149. },
  150. // 提交
  151. submitData() {
  152. let required = true
  153. for (let key in this.shopInfo) {
  154. if (!this.shopInfo[key]) {
  155. required = false
  156. }
  157. }
  158. if (!required) {
  159. this.$refs.uTips.show({
  160. title: '请填写必填项',
  161. type: 'warning',
  162. })
  163. return false
  164. }
  165. if (this.fileList.length != 3) {
  166. this.$refs.uTips.show({
  167. title: '店铺主页图需上传三张',
  168. type: 'warning',
  169. })
  170. return false
  171. }
  172. NET.request(API.editShopRegisterInfo, {
  173. ...this.shopInfo,
  174. address: this.shopInfo.companyAddressProvince + '-' + this.shopInfo.companyAddressCity + '-' + this.shopInfo.companyAddressDistrict,
  175. companyAddress: this.shopInfo.companyAddressProvince + '-' + this.shopInfo.companyAddressCity + '-' + this.shopInfo
  176. .companyAddressDistrict,
  177. storeImgUrl: this.fileList.join(',')
  178. }, 'PUT').then(res => {
  179. this.$refs.uTips.show({
  180. title: '编辑成功',
  181. type: 'success',
  182. })
  183. setTimeout(() => {
  184. uni.switchTab({
  185. url: '/pages/user/index'
  186. })
  187. }, 1000)
  188. }).catch(res => {
  189. this.$refs.uTips.show({
  190. title: '编辑失败',
  191. type: 'warning',
  192. })
  193. })
  194. },
  195. },
  196. }
  197. </script>
  198. <style lang="less" scoped>
  199. page {
  200. width: 100%;
  201. height: 100%;
  202. }
  203. .container {
  204. width: 100%;
  205. height: 100%;
  206. float: left;
  207. overflow-y: auto;
  208. .form-info {
  209. width: 100%;
  210. float: left;
  211. /deep/.u-label-text {
  212. color: #333333;
  213. }
  214. /deep/.u-cell_title {
  215. color: #333333;
  216. }
  217. .id-card-box {
  218. display: flex;
  219. .id-card {
  220. width: 164px;
  221. height: 140px;
  222. box-sizing: border-box;
  223. margin-right: 14px;
  224. border-radius: 6px;
  225. }
  226. }
  227. .license-box {
  228. .license-img {
  229. width: 345px;
  230. height: 145px;
  231. }
  232. }
  233. .license-text {
  234. width: 345px;
  235. height: 30px;
  236. margin-top: 5px;
  237. font-size: 15px;
  238. font-family: PingFang SC;
  239. color: #656565;
  240. line-height: 30px;
  241. text-align: center;
  242. }
  243. }
  244. .form-handle {
  245. width: calc(100% - 30px);
  246. float: left;
  247. height: 40px;
  248. margin: 30px 15px 20px 15px;
  249. .handle-custom {
  250. background-color: #51A539;
  251. }
  252. // /deep/.u-btn--success--disabled {
  253. // background-color: #999999 !important;
  254. // }
  255. }
  256. }
  257. </style>