register.vue 11 KB

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