register.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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"></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="请上传店铺主图(0/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. <u-upload :action="uploadUrl" :file-list="defaultList3" :form-data="uploadData" @on-success="uploadIdCardSuccess1"
  20. @on-error="uploadError" :custom-btn="true" max-count="1">
  21. <view slot="addBtn" class="id-card card-img1">拍摄正面</view>
  22. </u-upload>
  23. <u-upload :action="uploadUrl" :file-list="defaultList4" :form-data="uploadData" @on-success="uploadIdCardSuccess2"
  24. @on-error="uploadError" :custom-btn="true" max-count="1">
  25. <view slot="addBtn" class="id-card card-img1">拍摄反面</view>
  26. </u-upload>
  27. </view>
  28. </u-cell-item>
  29. <u-cell-item title="请上传营业执照照片" :arrow="false">
  30. <view slot="label" class="license-box">
  31. <u-upload :action="uploadUrl" :file-list="defaultList5" :form-data="uploadData" @on-success="uploadLicenseSuccess"
  32. @on-error="uploadError" :custom-btn="true" max-count="1">
  33. <view slot="addBtn" class="license-img"></view>
  34. </u-upload>
  35. <view class="license-text"> 营业执照</view>
  36. </view>
  37. </u-cell-item>
  38. <u-field label="法人姓名" placeholder="请输入法人姓名" label-width="180" v-model="shopInfo.duty"></u-field>
  39. <u-cell-item title="所在城市" @click="regionShow = true">
  40. <text v-show="shopInfo.companyAddressProvince">{{shopInfo.companyAddressProvince}}-{{shopInfo.companyAddressCity}}-{{shopInfo.companyAddressDistrict}}</text>
  41. </u-cell-item>
  42. <u-field label="联系方式" placeholder="请输入联系方式" label-width="180" v-model="shopInfo.contactTel"></u-field>
  43. <u-field label="收款人姓名" placeholder="请输入收款人姓名" label-width="180" v-model="shopInfo.collectionName"></u-field>
  44. <u-field label="户名" placeholder="请输入户名" label-width="180" v-model="shopInfo.bankAccountName"></u-field>
  45. <u-field label="银行名称" placeholder="请输入银行名称" label-width="180" v-model="shopInfo.bankAllName"></u-field>
  46. <u-field label="银行卡号" placeholder="请输入银行卡号" label-width="180" v-model="shopInfo.bankNumber"></u-field>
  47. </u-cell-group>
  48. <view class="form-handle">
  49. <u-button type="success" shape="circle" :ripple="true" @click="submitData" class="handle-custom">提交</u-button>
  50. </view>
  51. <u-picker mode="region" v-model="regionShow" @confirm="setRegion"></u-picker>
  52. <u-top-tips ref="uTips"></u-top-tips>
  53. </view>
  54. </template>
  55. <script>
  56. const NET = require('@/utils/request')
  57. const API = require('@/config/api')
  58. export default {
  59. data() {
  60. return {
  61. type: '',
  62. shopInfo: {
  63. name: '',
  64. logo: '',
  65. idCardCopyFilePath: '',
  66. idCardNationalFilePath: '',
  67. businessLicenseCopyFilePath: '',
  68. duty: '',
  69. companyAddressProvince: '',
  70. companyAddressCity: '',
  71. companyAddressDistrict: '',
  72. contactTel: '',
  73. collectionName: '',
  74. bankAccountName: '',
  75. bankAllName: '',
  76. bankNumber: '',
  77. },
  78. regionShow: false,
  79. uploadData: {
  80. folderId: 0,
  81. },
  82. uploadUrl: '',
  83. fileList: [],
  84. defaultList1: [],
  85. defaultList2: [],
  86. defaultList3: [],
  87. defaultList4: [],
  88. defaultList5: [],
  89. }
  90. },
  91. onLoad(options) {
  92. this.uploadUrl = API.uploadFile
  93. this.type = options.type
  94. if (options.type == 'edit') {
  95. NET.request(API.getShopRegisterInfo, {}, 'GET').then(res => {
  96. this.shopInfo = {
  97. name: res.data.name,
  98. logo: res.data.logo,
  99. idCardCopyFilePath: res.data.idCardCopyFilePath,
  100. idCardNationalFilePath: res.data.idCardNationalFilePath,
  101. businessLicenseCopyFilePath: res.data.businessLicenseCopyFilePath,
  102. duty: res.data.duty,
  103. companyAddressProvince: res.data.companyAddressProvince,
  104. companyAddressCity: res.data.companyAddressCity,
  105. companyAddressDistrict: res.data.companyAddressDistrict,
  106. contactTel: res.data.contactTel,
  107. collectionName: res.data.collectionName,
  108. bankAccountName: res.data.bankAccountName,
  109. bankAllName: res.data.bankAllName,
  110. bankNumber: res.data.bankNumber,
  111. }
  112. this.fileList = res.data.storeImgUrl.split(',')
  113. this.defaultList1 = [{
  114. url: res.data.logo
  115. }]
  116. this.defaultList2 = res.data.storeImgUrl.split(',').map(site => {
  117. return {
  118. url: site
  119. }
  120. })
  121. this.defaultList3 = [{
  122. url: res.data.idCardCopyFilePath
  123. }]
  124. this.defaultList4 = [{
  125. url: res.data.idCardNationalFilePath
  126. }]
  127. this.defaultList5 = [{
  128. url: res.data.businessLicenseCopyFilePath
  129. }]
  130. }).catch(res => {
  131. this.$refs.uTips.show({
  132. title: '获取注册信息失败',
  133. type: 'warning',
  134. })
  135. })
  136. }
  137. },
  138. methods: {
  139. // logo上传成功回调
  140. logoUploadSuccess(res, index, lists, name) {
  141. this.shopInfo.logo = res.data.url
  142. this.$refs.uTips.show({
  143. title: 'logo上传成功',
  144. type: 'success',
  145. })
  146. return true
  147. },
  148. // 文件上传成功回调
  149. uploadSuccess(res, index, lists, name) {
  150. this.fileList.push(res.data.url)
  151. this.$refs.uTips.show({
  152. title: '文件上传成功',
  153. type: 'success',
  154. })
  155. return true
  156. },
  157. // 身份证正面上传成功回调
  158. uploadIdCardSuccess1(res, index, lists, name) {
  159. this.shopInfo.idCardCopyFilePath = res.data.url
  160. this.$refs.uTips.show({
  161. title: '身份证正面照片上传成功',
  162. type: 'success',
  163. })
  164. return true
  165. },
  166. // 身份证反面上传成功回调
  167. uploadIdCardSuccess2(res, index, lists, name) {
  168. this.shopInfo.idCardNationalFilePath = res.data.url
  169. this.$refs.uTips.show({
  170. title: '身份证反面照片上传成功',
  171. type: 'success',
  172. })
  173. return true
  174. },
  175. // 营业执照上传成功回调
  176. uploadLicenseSuccess(res, index, lists, name) {
  177. this.shopInfo.businessLicenseCopyFilePath = res.data.url
  178. this.$refs.uTips.show({
  179. title: '营业执照照片上传成功',
  180. type: 'success',
  181. })
  182. return true
  183. },
  184. // 文件上传失败回调
  185. uploadError(res, index, lists, name) {
  186. this.$refs.uTips.show({
  187. title: '文件上传失败',
  188. type: 'warning',
  189. })
  190. },
  191. // 移除文件回调
  192. uploadRemove(index, lists, name) {
  193. this.fileList.splice(index, 1)
  194. },
  195. // 设置地址
  196. setRegion(data) {
  197. this.shopInfo.companyAddressProvince = data.province.label
  198. this.shopInfo.companyAddressCity = data.city.label
  199. this.shopInfo.companyAddressDistrict = data.area.label
  200. },
  201. // 提交
  202. submitData() {
  203. let required = true
  204. for (let key in this.shopInfo) {
  205. if (!this.shopInfo[key]) {
  206. required = false
  207. }
  208. }
  209. if (!required) {
  210. this.$refs.uTips.show({
  211. title: '请填写必填项',
  212. type: 'warning',
  213. })
  214. return false
  215. }
  216. if (this.fileList.length != 3) {
  217. this.$refs.uTips.show({
  218. title: '店铺主页图需上传三张',
  219. type: 'warning',
  220. })
  221. return false
  222. }
  223. if (this.type == 'edit') {
  224. NET.request(API.editShopRegisterInfo, {
  225. ...this.shopInfo,
  226. address: this.shopInfo.companyAddressProvince + '-' + this.shopInfo.companyAddressCity + '-' + this.shopInfo.companyAddressDistrict,
  227. companyAddress: this.shopInfo.companyAddressProvince + '-' + this.shopInfo.companyAddressCity + '-' + this.shopInfo.companyAddressDistrict,
  228. storeImgUrl: this.fileList.join(',')
  229. }, 'PUT').then(res => {
  230. this.$refs.uTips.show({
  231. title: '编辑成功',
  232. type: 'success',
  233. })
  234. setTimeout(() => {
  235. uni.switchTab({
  236. url: '/pages/index/registerState'
  237. });
  238. }, 1000)
  239. }).catch(res => {
  240. this.$refs.uTips.show({
  241. title: '编辑失败',
  242. type: 'warning',
  243. })
  244. })
  245. } else {
  246. NET.request(API.submitShopRegisterInfo, {
  247. ...this.shopInfo,
  248. address: this.shopInfo.companyAddressProvince + '-' + this.shopInfo.companyAddressCity + '-' + this.shopInfo.companyAddressDistrict,
  249. companyAddress: this.shopInfo.companyAddressProvince + '-' + this.shopInfo.companyAddressCity + '-' + this.shopInfo.companyAddressDistrict,
  250. storeImgUrl: this.fileList.join(',')
  251. }, 'POST').then(res => {
  252. this.$refs.uTips.show({
  253. title: '注册成功',
  254. type: 'success',
  255. })
  256. setTimeout(() => {
  257. uni.navigateTo({
  258. url: '/pages/index/registerState'
  259. });
  260. }, 1000)
  261. }).catch(res => {
  262. this.$refs.uTips.show({
  263. title: '注册失败',
  264. type: 'warning',
  265. })
  266. })
  267. }
  268. },
  269. },
  270. }
  271. </script>
  272. <style lang="less" scoped>
  273. page {
  274. width: 100%;
  275. height: 100%;
  276. }
  277. .container {
  278. width: 100%;
  279. height: 100%;
  280. float: left;
  281. overflow-y: auto;
  282. .form-info {
  283. width: 100%;
  284. float: left;
  285. /deep/.u-label-text {
  286. color: #333333;
  287. }
  288. /deep/.u-cell_title {
  289. color: #333333;
  290. }
  291. .id-card-box {
  292. display: flex;
  293. .id-card {
  294. width: 164px;
  295. height: 140px;
  296. box-sizing: border-box;
  297. padding-top: 110px;
  298. margin-right: 14px;
  299. background-color: #51A539;
  300. background-size: 164px 110px;
  301. background-position: center top;
  302. background-repeat: no-repeat;
  303. border-radius: 6px;
  304. font-size: 15px;
  305. font-family: PingFang SC;
  306. color: #FFFFFF;
  307. line-height: 30px;
  308. text-align: center;
  309. }
  310. .card-img1 {
  311. background-image: url(@/static/images/card-img1.png);
  312. }
  313. .card-img2 {
  314. background-image: url(@/static/images/card-img2.png);
  315. }
  316. /deep/.u-list-item {
  317. width: 164px !important;
  318. height: 110px !important;
  319. }
  320. }
  321. .license-box {
  322. .license-img {
  323. width: 345px;
  324. height: 145px;
  325. background-size: 345px 145px;
  326. background-position: center top;
  327. background-repeat: no-repeat;
  328. background-image: url(@/static/images/license-img.png);
  329. }
  330. /deep/.u-list-item {
  331. width: 345px !important;
  332. height: 145px !important;
  333. }
  334. }
  335. .license-text {
  336. width: 345px;
  337. height: 30px;
  338. margin-top: 5px;
  339. font-size: 15px;
  340. font-family: PingFang SC;
  341. color: #656565;
  342. line-height: 30px;
  343. text-align: center;
  344. }
  345. }
  346. .form-handle {
  347. width: calc(100% - 30px);
  348. float: left;
  349. height: 40px;
  350. margin: 30px 15px 20px 15px;
  351. .handle-custom {
  352. background-color: #51A539;
  353. }
  354. // /deep/.u-btn--success--disabled {
  355. // background-color: #999999 !important;
  356. // }
  357. }
  358. }
  359. </style>