settledMerchants.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. <template>
  2. <view class="content">
  3. <view v-if="state == 0">
  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" @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">上传营业执照</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="/static/images/comment//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="/static/images/comment/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="/static/images/comment/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. </view>
  92. </template>
  93. <script>
  94. import $api from '@/static/js/api.js'
  95. var that = ''
  96. export default {
  97. data() {
  98. return {
  99. info: {
  100. id: '',
  101. name: '',
  102. address: '',
  103. contacts: '',
  104. phone: '',
  105. introduction: '',
  106. fileList1: [],
  107. fileList2: [],
  108. fileList3: [],
  109. },
  110. addressObj: {},
  111. agree: false,
  112. state: 0,
  113. reason: '',
  114. fileList1: '',
  115. fileList2: '',
  116. fileList3: '',
  117. }
  118. },
  119. onLoad() {
  120. that = this
  121. that.getPreData()
  122. },
  123. methods: {
  124. getPreData() {
  125. var pages = getCurrentPages()
  126. var prePage = pages[pages.length - 2]
  127. var merchants = prePage.$vm.user.merchants
  128. if (merchants) {
  129. that.info = {
  130. name: merchants.name,
  131. contacts: merchants.contact_name,
  132. phone: merchants.contact_phone,
  133. introduction: merchants.intro,
  134. fileList1: [],
  135. fileList2: [],
  136. fileList3: [],
  137. // fileList1: merchants.business_img.split(','),
  138. id: merchants.id
  139. }
  140. /* that.info.fileList3.push({
  141. url: merchants.business_img
  142. }) */
  143. if(merchants.head_img !== null) {
  144. that.info.fileList1.push({
  145. url: merchants.head_img
  146. })
  147. that.fileList1 = merchants.head_img
  148. }
  149. var imgs = merchants.imgs_videos.splice(',')
  150. for(var i=0;i<imgs.length;i++) {
  151. that.info.fileList2.push({
  152. url: imgs[i]
  153. })
  154. }
  155. that.fileList2 = merchants.imgs_videos
  156. that.info.fileList3.push({
  157. url: merchants.business_img
  158. })
  159. that.fileList3 = merchants.business_img
  160. console.log(that.info);
  161. that.addressObj = {
  162. address: merchants.address,
  163. province: merchants.province,
  164. city:merchants.city,
  165. area:merchants.area,
  166. }
  167. that.state = merchants.audit
  168. that.reason = merchants.why
  169. }
  170. },
  171. selectmap() {
  172. console.log('选择地址');
  173. uni.getLocation({
  174. type: 'wgs84',
  175. success: (res)=>{
  176. console.log(res);
  177. if(res.longitude && res.latitude){
  178. $api.jump('/pages/user/map?lng='+res.longitude+'&lat='+res.latitude)
  179. }
  180. },
  181. fail:()=>{
  182. uni.getSetting({
  183. success: (res) => {
  184. console.log(res);
  185. var status = res.authSetting;
  186. if(!status['scope.userLocation']){
  187. uni.showModal({
  188. title:"是否授权当前位置",
  189. content:"需要获取您的地理位置,请确认授权,否则地图功能将无法使用",
  190. success:(tip)=>{
  191. if(tip.confirm){
  192. uni.openSetting({
  193. success:(data)=>{
  194. if(data.authSetting['scope.userLocation']===true){
  195. uni.showToast({
  196. title:"授权成功",
  197. icon:"success",
  198. duration:1000
  199. })
  200. uni.getLocation({
  201. type: 'wgs84',
  202. success: (res)=>{
  203. console.log('当前位置的经度:' + res.longitude);
  204. console.log('当前位置的纬度:' + res.latitude);
  205. $api.jump('/pages/user/map?lng='+res.longitude+'&lat='+res.latitude)
  206. }
  207. })
  208. }else{
  209. uni.showToast({
  210. title:"授权失败",
  211. icon:"none",
  212. duration:1000
  213. })
  214. }
  215. }
  216. })
  217. }
  218. }
  219. })
  220. }else{
  221. uni.getLocation({
  222. type: 'wgs84',
  223. success: (res)=>{
  224. console.log('当前位置的经度:' + res.longitude);
  225. console.log('当前位置的纬度:' + res.latitude);
  226. $api.jump('/pages/user/map?lng='+res.longitude+'&lat='+res.latitude)
  227. }
  228. })
  229. }
  230. },
  231. fail: (res) => {
  232. uni.showToast({
  233. title:"调用授权窗口失败",
  234. icon:"none",
  235. duration:1000
  236. })
  237. }
  238. })
  239. }
  240. })
  241. },
  242. // 删除图片
  243. deletePic(event) {
  244. // that.userInfo.imgList.splice(event.index, 1)
  245. console.log(event)
  246. this.info[`fileList${event.name}`].splice(event.index, 1)
  247. },
  248. // 新增图片
  249. async afterRead(event) {
  250. console.log(`fileList${event.name}`);
  251. console.log(this.info[`fileList${event.name}`]);
  252. let lists = [].concat(event.file)
  253. let fileListLen = this.info[`fileList${event.name}`].length
  254. lists.map((item) => {
  255. this.info[`fileList${event.name}`].push({
  256. ...item,
  257. status: 'uploading',
  258. message: '上传中'
  259. })
  260. })
  261. for (let i = 0; i < lists.length; i++) {
  262. const result = await this.uploadFilePromise(lists[i].url)
  263. let item = this.info[`fileList${event.name}`][fileListLen]
  264. this.info[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  265. status: 'success',
  266. message: '',
  267. url: result.url
  268. }))
  269. fileListLen++
  270. }
  271. if(that.info[`fileList${event.name}`].length > 0) {
  272. for(var i=0;i<that.info[`fileList${event.name}`].length;i++) {
  273. if(i == that.info[`fileList${event.name}`].length -1) {
  274. that[`fileList${event.name}`] += that.info[`fileList${event.name}`][i].url
  275. } else {
  276. that[`fileList${event.name}`] += that.info[`fileList${event.name}`][i].url + ','
  277. }
  278. }
  279. }
  280. },
  281. // 上传图片
  282. uploadFilePromise(url) {
  283. return new Promise((resolve, reject) => {
  284. let a = uni.uploadFile({
  285. url: $api.config.baseUrl + '/data/api.auth.Center/upload', // 仅为示例,非真实的接口地址
  286. filePath: url,
  287. name: 'file',
  288. header: {
  289. 'content-type': 'application/x-www-form-urlencoded',
  290. 'api-token': uni.getStorageSync('token').token?uni.getStorageSync('token').token:'',
  291. 'api-name': 'wxapp'
  292. },
  293. formData: {
  294. user: 'test'
  295. },
  296. success: (res) => {
  297. setTimeout(() => {
  298. var data = JSON.parse(res.data)
  299. resolve(data.data)
  300. }, 1000)
  301. }
  302. });
  303. })
  304. },
  305. // 阅读并同意
  306. checkboxChange(n) {
  307. that.agree = !that.agree
  308. },
  309. settled() {
  310. var business_img = ""
  311. 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')) {
  312. if(that.agree) {
  313. /* if(that.info.fileList3.length > 0) {
  314. for(var i=0;i<that.info.fileList1.length;i++) {
  315. business_img += that.info.fileList1[i].url
  316. }
  317. } */
  318. $api.req({
  319. url: '/data/api.auth.Center/addupmerchants',
  320. method: 'POST',
  321. data: {
  322. name: that.info.name,
  323. province: that.addressObj.province,
  324. city: that.addressObj.city,
  325. area: that.addressObj.area,
  326. address: that.addressObj.address,
  327. contact_name: that.info.contacts,
  328. contact_phone: that.info.phone,
  329. intro: that.info.introduction,
  330. head_img: that.fileList1,
  331. imgs_videos: that.fileList2,
  332. business_img: that.fileList3,
  333. id: that.info.id?that.info.id: ''
  334. }
  335. }, function(res) {
  336. if(res.code == 1) {
  337. $api.info(res.info)
  338. that.state = 1
  339. }
  340. })
  341. }else {
  342. $api.info('请先阅读并同意《商家入驻规则》')
  343. }
  344. }
  345. },
  346. edit() {
  347. that.state = 0
  348. },
  349. result() {
  350. $api.jump('/pages/tabbar/mine/mine',3)
  351. }
  352. },
  353. }
  354. </script>
  355. <style lang="scss" scoped>
  356. .content::v-deep {
  357. background: #F4F4F4;
  358. padding: 20rpx 30rpx;
  359. .box {
  360. width: 100%;
  361. background: #FFFFFF;
  362. border-radius: 28rpx;
  363. padding: 28rpx 20rpx;
  364. box-sizing: border-box;
  365. margin-bottom: 16rpx;
  366. .title {
  367. font-size: 32rpx;
  368. color: #222222;
  369. font-weight: 600;
  370. line-height: 44px;
  371. }
  372. .upload_bg {
  373. width: 200rpx;
  374. height: 200rpx;
  375. background: #F4F4F4;
  376. border-radius: 20rpx;
  377. }
  378. .upload_text {
  379. font-size: 26rpx;
  380. font-weight: 400;
  381. color: #777777;
  382. line-height: 36rpx;
  383. padding-top: 20rpx;
  384. }
  385. .cell {
  386. width: 100%;
  387. padding: 20rpx 0 28rpx;
  388. border-bottom: 1rpx solid #f4f4f4;
  389. .left {
  390. width: 25%;
  391. font-size: 28rpx;
  392. color: #222;
  393. position: relative;
  394. padding-left: 10rpx;
  395. }
  396. .left::before {
  397. content: "*";
  398. position: absolute;
  399. top: 0rpx;
  400. left: -5rpx;
  401. color: #FF0D0D;
  402. font-size: 20rpx;
  403. }
  404. .u-input {
  405. font-size: 28rpx;
  406. color: #222;
  407. }
  408. .img_title {
  409. font-size: 28rpx;
  410. color: #444;
  411. }
  412. .upload_img {
  413. width: 670rpx;
  414. height: 404rpx;
  415. background-color: #fff;
  416. border-radius: 20rpx;
  417. margin: 28rpx 0 0;
  418. padding: 20rpx 0;
  419. border: 1rpx dashed #e0e0e0;
  420. }
  421. .u-upload__wrap {
  422. display: flex;
  423. align-items: center !important;
  424. justify-content: center !important;
  425. }
  426. .u-textarea {
  427. margin: 28rpx auto 0;
  428. background-color: #f4f4f4;
  429. border-radius: 28rpx;
  430. box-sizing: border-box;
  431. padding: 24rpx;
  432. width: 610rpx;
  433. }
  434. }
  435. }
  436. .text {
  437. font-size: 24rpx;
  438. color: #9c9c9c;
  439. }
  440. .read {
  441. color: #2a63f3;
  442. }
  443. .button {
  444. width: 100%;
  445. height: 88rpx;
  446. background-color: #506dff;
  447. border-radius: 50rpx;
  448. box-shadow: 0 4rpx 28rpx 0 rgba(132,123,255,0.4);
  449. font-size: 40rpx;
  450. color: #fff;
  451. margin: 40rpx 0 36rpx;
  452. }
  453. .box1 {
  454. width: 100%;
  455. // height: 100vh;
  456. background-color: #fff;
  457. padding-bottom: 80rpx;
  458. .box1_img {
  459. width: 124rpx;
  460. height: 124rpx;
  461. margin: 108rpx 0 40rpx;
  462. }
  463. .box1_title {
  464. font-size: 32rpx;
  465. color: #222;
  466. margin-bottom: 24rpx;
  467. }
  468. .box1_subTitle {
  469. margin: 12rpx 0;
  470. font-size: 26rpx;
  471. color: #999999;
  472. }
  473. .btn {
  474. width: 530rpx;
  475. height: 88rpx;
  476. background-color: #506dff;
  477. color: #fff;
  478. text-align: center;
  479. line-height: 88rpx;
  480. border-radius: 44rpx;
  481. font-size: 36rpx;
  482. margin-top: 122rpx;
  483. }
  484. }
  485. }
  486. </style>