registerForm.vue 8.4 KB

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