settledMerchants.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. <template>
  2. <view class="content">
  3. <view v-if="state == 0 || state == 2">
  4. <view class="box">
  5. <view class="title">商家信息</view>
  6. <view class="cell vflex">
  7. <view class="img_title">商家头像</view>
  8. <view style="width: 220rpx;height: 220rpx;padding-top: 28rpx;">
  9. <u-upload :fileList="info.fileList1" @afterRead="afterRead" @delete="deletePic" :maxCount="1" name="1" multiple :previewFullImage="true" width="220rpx" height="220rpx">
  10. <view class="vflex acenter jcenter upload_bg">
  11. <u-icon name="plus" color="#929292" size="20"></u-icon>
  12. <view class="upload_text">上传图片</view>
  13. </view>
  14. </u-upload>
  15. </view>
  16. </view>
  17. <view class="hflex acenter jbetween cell">
  18. <view class="left">商家名称</view>
  19. <u-input v-model="info.name" border="none" placeholder="请输入商家名称" inputAlign="right"></u-input>
  20. </view>
  21. <view class="hflex acenter jbetween cell" @click="selectmap">
  22. <view class="left">商家地址</view>
  23. <u-input v-model="addressObj.address" border="none" disabled disabledColor="#fff" placeholder="请选择" inputAlign="right" suffixIcon="map-fill" suffixIconStyle="color: #B7B7B7"></u-input>
  24. </view>
  25. <view class="hflex acenter jbetween cell">
  26. <view class="left">联系人</view>
  27. <u-input v-model="info.contacts" border="none" placeholder="请输入联系人姓名" inputAlign="right"></u-input>
  28. </view>
  29. <view class="hflex acenter jbetween cell">
  30. <view class="left">联系电话</view>
  31. <u-input v-model="info.phone" border="none" placeholder="请输入联系电话" inputAlign="right"></u-input>
  32. </view>
  33. <view class="vflex cell" style="border: none;">
  34. <view class="img_title">商家简介</view>
  35. <u--textarea v-model="info.introduction" placeholder="在此输入商家简介内容" ></u--textarea>
  36. </view>
  37. <view class="vflex">
  38. <view class="img_title">图片及视频</view>
  39. <view class="hflex fwrap" style="padding-top: 28rpx;">
  40. <u-upload :fileList="info.fileList2" accept="media" @afterRead="afterRead" @delete="deletePic" :maxCount="9" name="2" multiple :previewFullImage="true" width="200rpx" height="200rpx">
  41. <view class="vflex acenter jcenter upload_bg">
  42. <u-icon name="plus" color="#929292" size="20"></u-icon>
  43. <view class="upload_text">上传图片或视频</view>
  44. </view>
  45. </u-upload>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="box">
  50. <view class="cell" style="border: none;padding: none;">
  51. <view class="left" style="width: 60%;">上传营业执照</view>
  52. <view class="upload_img vflex acenter jcenter">
  53. <u-upload :fileList="info.fileList3" @afterRead="afterRead" @delete="deletePic" :maxCount="1" name="3" multiple :previewFullImage="true" width="550rpx" height="324rpx">
  54. <image src="https://ship-expert.zhousi.hdlkeji.com/common//upload-business.png" style="width: 550rpx;height: 324rpx;"></image>
  55. </u-upload>
  56. <view class="hflex acenter ">
  57. <u-icon name="camera" color="#999999" size="16"></u-icon>
  58. <view class="">点击上传营业执照</view>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. <view class="hflex acenter">
  64. <u-checkbox-group @change="checkboxChange">
  65. <u-checkbox v-model="agree" shape="circle"></u-checkbox>
  66. </u-checkbox-group>
  67. <view class="text">阅读并同意<span class="read" @click="open">《商家入驻规则》</span></view>
  68. </view>
  69. <view class="button hflex acenter jcenter" @click="settled">
  70. <view>{{state == 2?'修改入驻':'立即入驻'}}</view>
  71. </view>
  72. </view>
  73. <view v-if="state == 1">
  74. <view class="box1 vflex acenter jcenter">
  75. <image src="https://ship-expert.zhousi.hdlkeji.com/common/wait.png" class="box1_img"></image>
  76. <view class="box1_title">审核中</view>
  77. <view class="box1_subTitle">预计审核时间3个工作日</view>
  78. <view class="box1_subTitle">请留意当前页面变动</view>
  79. <view class="btn" @click="result">返回</view>
  80. </view>
  81. </view>
  82. <view v-if="state == 3">
  83. <view class="box1 vflex acenter jcenter">
  84. <image src="https://ship-expert.zhousi.hdlkeji.com/common/error.png" class="box1_img"></image>
  85. <view class="box1_title">审核失败</view>
  86. <view class="box1_subTitle">驳回原因</view>
  87. <view class="box1_subTitle">{{reason}}<span style="color: #506dff;margin-left: 8rpx;" @click="edit">立即修改></span></view>
  88. <view class="btn" @click="result">返回</view>
  89. </view>
  90. </view>
  91. <u-modal :show="showProtocol" :title="protocolTitle" confirmColor="#2988FE" @confirm="isRead" confirmText="我已阅读">
  92. <view class="slot-content">
  93. <rich-text :nodes="protocolContent"></rich-text>
  94. </view>
  95. </u-modal>
  96. </view>
  97. </template>
  98. <script>
  99. import $api from '@/static/js/api.js'
  100. var that = ''
  101. export default {
  102. data() {
  103. return {
  104. info: {
  105. id: '',
  106. name: '',
  107. address: '',
  108. contacts: '',
  109. phone: '',
  110. introduction: '',
  111. fileList1: [],
  112. fileList2: [],
  113. fileList3: [],
  114. },
  115. addressObj: {},
  116. agree: false,
  117. showProtocol: false,
  118. protocolTitle: '',
  119. protocolContent: '',
  120. state: 0,
  121. reason: '',
  122. fileList1: '',
  123. fileList2: '',
  124. fileList3: '',
  125. }
  126. },
  127. onLoad() {
  128. that = this
  129. that.getPreData()
  130. },
  131. methods: {
  132. getPreData() {
  133. var pages = getCurrentPages()
  134. var prePage = pages[pages.length - 2]
  135. var merchants = prePage.$vm.user.merchants
  136. if (merchants) {
  137. that.info = {
  138. name: merchants.name,
  139. contacts: merchants.contact_name,
  140. phone: merchants.contact_phone,
  141. introduction: merchants.intro,
  142. fileList1: [],
  143. fileList2: [],
  144. fileList3: [],
  145. // fileList1: merchants.business_img.split(','),
  146. id: merchants.id
  147. }
  148. /* that.info.fileList3.push({
  149. url: merchants.business_img
  150. }) */
  151. if(merchants.head_img !== null) {
  152. that.info.fileList1.push({
  153. url: merchants.head_img
  154. })
  155. that.fileList1 = merchants.head_img
  156. }
  157. var imgs = merchants.imgs_videos.splice(',')
  158. for(var i=0;i<imgs.length;i++) {
  159. that.info.fileList2.push({
  160. url: imgs[i]
  161. })
  162. }
  163. that.fileList2 = merchants.imgs_videos
  164. that.info.fileList3.push({
  165. url: merchants.business_img
  166. })
  167. that.fileList3 = merchants.business_img
  168. console.log(that.info);
  169. that.addressObj = {
  170. address: merchants.address,
  171. province: merchants.province,
  172. city:merchants.city,
  173. area:merchants.area,
  174. longitude: merchants.longitude,
  175. latitude: merchants.latitude,
  176. }
  177. that.state = merchants.audit
  178. that.reason = merchants.why
  179. }
  180. },
  181. selectmap() {
  182. console.log('选择地址');
  183. uni.getLocation({
  184. type: 'wgs84',
  185. success: (res)=>{
  186. console.log(res);
  187. if(res.longitude && res.latitude){
  188. $api.jump('/pages/user/map?lng='+res.longitude+'&lat='+res.latitude)
  189. }
  190. },
  191. fail:()=>{
  192. uni.getSetting({
  193. success: (res) => {
  194. console.log(res);
  195. var status = res.authSetting;
  196. if(!status['scope.userLocation']){
  197. uni.showModal({
  198. title:"是否授权当前位置",
  199. content:"需要获取您的地理位置,请确认授权,否则地图功能将无法使用",
  200. success:(tip)=>{
  201. if(tip.confirm){
  202. uni.openSetting({
  203. success:(data)=>{
  204. if(data.authSetting['scope.userLocation']===true){
  205. uni.showToast({
  206. title:"授权成功",
  207. icon:"success",
  208. duration:1000
  209. })
  210. uni.getLocation({
  211. type: 'wgs84',
  212. success: (res)=>{
  213. console.log('当前位置的经度:' + res.longitude);
  214. console.log('当前位置的纬度:' + res.latitude);
  215. $api.jump('/pages/user/map?lng='+res.longitude+'&lat='+res.latitude)
  216. }
  217. })
  218. }else{
  219. uni.showToast({
  220. title:"授权失败",
  221. icon:"none",
  222. duration:1000
  223. })
  224. }
  225. }
  226. })
  227. }
  228. }
  229. })
  230. }else{
  231. uni.getLocation({
  232. type: 'wgs84',
  233. success: (res)=>{
  234. console.log('当前位置的经度:' + res.longitude);
  235. console.log('当前位置的纬度:' + res.latitude);
  236. $api.jump('/pages/user/map?lng='+res.longitude+'&lat='+res.latitude)
  237. }
  238. })
  239. }
  240. },
  241. fail: (res) => {
  242. uni.showToast({
  243. title:"调用授权窗口失败",
  244. icon:"none",
  245. duration:1000
  246. })
  247. }
  248. })
  249. }
  250. })
  251. },
  252. // 删除图片
  253. deletePic(event) {
  254. // that.userInfo.imgList.splice(event.index, 1)
  255. that[`fileList${event.name}`] = ''
  256. that.info[`fileList${event.name}`].splice(event.index, 1)
  257. if(that.info[`fileList${event.name}`].length > 0) {
  258. for(var i=0;i<that.info[`fileList${event.name}`].length;i++) {
  259. if(i == that.info[`fileList${event.name}`].length -1) {
  260. that[`fileList${event.name}`] += that.info[`fileList${event.name}`][i].url
  261. } else {
  262. that[`fileList${event.name}`] += that.info[`fileList${event.name}`][i].url + ','
  263. }
  264. }
  265. }
  266. },
  267. // 新增图片
  268. async afterRead(event) {
  269. uni.showLoading({
  270. title: '上传中',
  271. mask: true
  272. })
  273. console.log(`fileList${event.name}`);
  274. console.log(this.info[`fileList${event.name}`]);
  275. let lists = [].concat(event.file)
  276. let fileListLen = this.info[`fileList${event.name}`].length
  277. lists.map((item) => {
  278. this.info[`fileList${event.name}`].push({
  279. ...item,
  280. status: 'uploading',
  281. message: '上传中'
  282. })
  283. })
  284. for (let i = 0; i < lists.length; i++) {
  285. const result = await this.uploadFilePromise(lists[i].url)
  286. let item = this.info[`fileList${event.name}`][fileListLen]
  287. this.info[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  288. status: 'success',
  289. message: '',
  290. url: result.url
  291. }))
  292. fileListLen++
  293. if(lists.length - 1 == i) {
  294. uni.hideLoading()
  295. }
  296. }
  297. that[`fileList${event.name}`] = ''
  298. if(that.info[`fileList${event.name}`].length > 0) {
  299. for(var i=0;i<that.info[`fileList${event.name}`].length;i++) {
  300. if(i == that.info[`fileList${event.name}`].length -1) {
  301. that[`fileList${event.name}`] += that.info[`fileList${event.name}`][i].url
  302. } else {
  303. that[`fileList${event.name}`] += that.info[`fileList${event.name}`][i].url + ','
  304. }
  305. }
  306. }
  307. },
  308. // 上传图片
  309. uploadFilePromise(url) {
  310. return new Promise((resolve, reject) => {
  311. let a = uni.uploadFile({
  312. url: $api.config.baseUrl + '/data/api.auth.Center/upload',
  313. filePath: url,
  314. name: 'file',
  315. header: {
  316. 'content-type': 'application/x-www-form-urlencoded',
  317. 'api-token': uni.getStorageSync('token').token?uni.getStorageSync('token').token:'',
  318. 'api-name': 'wxapp'
  319. },
  320. formData: {
  321. user: 'test'
  322. },
  323. success: (res) => {
  324. setTimeout(() => {
  325. var data = JSON.parse(res.data)
  326. resolve(data.data)
  327. }, 1000)
  328. }
  329. });
  330. })
  331. },
  332. // 阅读并同意
  333. checkboxChange(n) {
  334. that.agree = !that.agree
  335. },
  336. settled() {
  337. uni.showLoading({
  338. title: '上传中',
  339. mask: true
  340. })
  341. var business_img = ""
  342. if ($api.formCheck(that.info.name,'required')&&$api.formCheck(that.addressObj.address,'required')&&$api.formCheck(that.info.contacts,'required')&&$api.formCheck(that.info.phone,'phone')&&$api.formCheck(that.info.introduction,'required')) {
  343. if(that.agree) {
  344. /* if(that.info.fileList3.length > 0) {
  345. for(var i=0;i<that.info.fileList1.length;i++) {
  346. business_img += that.info.fileList1[i].url
  347. }
  348. } */
  349. $api.req({
  350. url: '/data/api.auth.Center/addupmerchants',
  351. method: 'POST',
  352. data: {
  353. name: that.info.name,
  354. province: that.addressObj.province,
  355. city: that.addressObj.city,
  356. area: that.addressObj.area,
  357. address: that.addressObj.address,
  358. longitude: that.addressObj.longitude,
  359. latitude: that.addressObj.latitude,
  360. contact_name: that.info.contacts,
  361. contact_phone: that.info.phone,
  362. intro: that.info.introduction,
  363. head_img: that.fileList1,
  364. imgs_videos: that.fileList2,
  365. business_img: that.fileList3,
  366. id: that.info.id?that.info.id: ''
  367. }
  368. }, function(res) {
  369. uni.hideLoading()
  370. if(res.code == 1) {
  371. $api.info(res.info)
  372. that.state = 1
  373. }
  374. })
  375. }else {
  376. $api.info('请先阅读并同意《商家入驻规则》')
  377. uni.hideLoading()
  378. }
  379. } else {
  380. uni.hideLoading()
  381. }
  382. },
  383. edit() {
  384. that.state = 0
  385. },
  386. result() {
  387. $api.jump('/pages/tabbar/mine/mine',3)
  388. },
  389. open() {
  390. $api.req({
  391. url: '/data/api.auth.Center/getrule'
  392. }, function(res) {
  393. if (res.code == 1) {
  394. console.log(res);
  395. uni.setStorageSync('xieyi',res.data.business_join_rule)
  396. $api.jump('/pages/user/agreement?title=商家入驻规则')
  397. }
  398. })
  399. },
  400. isRead() {
  401. that.showProtocol = false
  402. that.agree = true
  403. },
  404. },
  405. }
  406. </script>
  407. <style lang="scss" scoped>
  408. .content::v-deep {
  409. background: #F4F4F4;
  410. padding: 20rpx 30rpx;
  411. .box {
  412. width: 100%;
  413. background: #FFFFFF;
  414. border-radius: 28rpx;
  415. padding: 28rpx 20rpx;
  416. box-sizing: border-box;
  417. margin-bottom: 16rpx;
  418. .title {
  419. font-size: 32rpx;
  420. color: #222222;
  421. font-weight: 600;
  422. line-height: 44px;
  423. }
  424. .upload_bg {
  425. width: 200rpx;
  426. height: 200rpx;
  427. background: #F4F4F4;
  428. border-radius: 20rpx;
  429. }
  430. .upload_text {
  431. font-size: 26rpx;
  432. font-weight: 400;
  433. color: #777777;
  434. line-height: 36rpx;
  435. padding-top: 20rpx;
  436. }
  437. .cell {
  438. width: 100%;
  439. padding: 20rpx 0 28rpx;
  440. border-bottom: 1rpx solid #f4f4f4;
  441. .left {
  442. width: 25%;
  443. font-size: 28rpx;
  444. color: #222;
  445. position: relative;
  446. padding-left: 10rpx;
  447. }
  448. .left::before {
  449. content: "*";
  450. position: absolute;
  451. top: 0rpx;
  452. left: -5rpx;
  453. color: #FF0D0D;
  454. font-size: 20rpx;
  455. }
  456. .u-input {
  457. font-size: 28rpx;
  458. color: #222;
  459. }
  460. .img_title {
  461. font-size: 28rpx;
  462. color: #444;
  463. }
  464. .upload_img {
  465. width: 670rpx;
  466. height: 404rpx;
  467. background-color: #fff;
  468. border-radius: 20rpx;
  469. margin: 28rpx 0 0;
  470. padding: 20rpx 0;
  471. border: 1rpx dashed #e0e0e0;
  472. }
  473. .u-upload__wrap {
  474. display: flex;
  475. align-items: center !important;
  476. justify-content: center !important;
  477. }
  478. .u-textarea {
  479. margin: 28rpx auto 0;
  480. background-color: #f4f4f4;
  481. border-radius: 28rpx;
  482. box-sizing: border-box;
  483. padding: 24rpx;
  484. width: 610rpx;
  485. }
  486. }
  487. }
  488. .text {
  489. font-size: 24rpx;
  490. color: #9c9c9c;
  491. }
  492. .read {
  493. color: #2a63f3;
  494. }
  495. .button {
  496. width: 100%;
  497. height: 88rpx;
  498. background-color: #506dff;
  499. border-radius: 50rpx;
  500. box-shadow: 0 4rpx 28rpx 0 rgba(132,123,255,0.4);
  501. font-size: 40rpx;
  502. color: #fff;
  503. margin: 40rpx 0 36rpx;
  504. }
  505. .box1 {
  506. width: 100%;
  507. // height: 100vh;
  508. background-color: #fff;
  509. padding-bottom: 80rpx;
  510. .box1_img {
  511. width: 124rpx;
  512. height: 124rpx;
  513. margin: 108rpx 0 40rpx;
  514. }
  515. .box1_title {
  516. font-size: 32rpx;
  517. color: #222;
  518. margin-bottom: 24rpx;
  519. }
  520. .box1_subTitle {
  521. margin: 12rpx 0;
  522. font-size: 26rpx;
  523. color: #999999;
  524. }
  525. .btn {
  526. width: 530rpx;
  527. height: 88rpx;
  528. background-color: #506dff;
  529. color: #fff;
  530. text-align: center;
  531. line-height: 88rpx;
  532. border-radius: 44rpx;
  533. font-size: 36rpx;
  534. margin-top: 122rpx;
  535. }
  536. }
  537. }
  538. </style>