shop-info.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  1. <template>
  2. <view class="shop_info">
  3. <view class="base_info" v-if="statusShow == 0">
  4. <view class="title">基本信息</view>
  5. <view class="info">
  6. <view class="flexB">
  7. <view class="label">店铺头像:</view>
  8. <view class="flexS">
  9. <image :src="info.img"></image>
  10. </view>
  11. </view>
  12. <view class="flexB">
  13. <view class="label">店铺名称:</view>
  14. <view class="inp flexS" style="font-size:32rpx;">{{ info.name | getName(10) }}的店铺</view>
  15. </view>
  16. <view class="flexB">
  17. <view class="label">商户电话:</view>
  18. <view class="flexB inp"><input type="text" disabled v-model="info.phone" /></view>
  19. </view>
  20. <view class="flexB">
  21. <view class="label">店铺地址:</view>
  22. <view class="flexB inp">
  23. <textarea disabled v-model="location" auto-height />
  24. <view>
  25. <text @click="edit(3)">{{ location ? '修改' : '添加' }}</text>
  26. <text class="iconfont iconiconfontjiantou2"></text>
  27. </view>
  28. </view>
  29. </view>
  30. <w-picker ref="Selector" mode="region" themeColor="#F76454" @confirm="onConfirm" />
  31. <view class="flexB">
  32. <view class="label">详细地址:</view>
  33. <view class="flexB inp"><input type="text" disabled v-model="adsParams.address" /></view>
  34. </view>
  35. <view class="flexT">
  36. <view class="label">微信二维码:</view>
  37. <view>
  38. <image :src="imgUrl" class="wx_img" @click="uploadCode"></image>
  39. <view v-if="info.qr_code" class="code_hint">点击二维码可重新上传</view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <!-- 修改店铺名称 -->
  45. <view class="edit_name" v-if="statusShow == 1">
  46. <view class="name">
  47. <view class="hint">名称建议在10字以内,超出在店铺页可能展示不全*</view>
  48. <input type="text" placeholder="在此修改店铺名称" placeholder-style="font-size:28rpx;color:#999;" v-model="name"
  49. maxlength="10" />
  50. <view class="notice">
  51. <view>好的店铺名称具备以下特点:</view>
  52. <view>1.简单易懂,朗朗上口,避免雷同,避免生僻字,尽量体现主营商品。</view>
  53. <view>2.凸显店铺特色,体现店长风格。</view>
  54. <view>3.不适用国家法律法规禁止的违规词、敏感词不出现。</view>
  55. <view>4.不出现“淘宝”“微信”“代理”等会屏蔽的词汇。</view>
  56. <view>5.建议12字以内,超出在店铺页面可能展示不全。</view>
  57. </view>
  58. <view class="sub_btn" @click="finish">完成</view>
  59. </view>
  60. </view>
  61. <!-- 修改店铺手机号 -->
  62. <view class="flexCC edit_phone" v-if="statusShow == 2">
  63. <view class="old" v-if="step == 0">
  64. <view class="hint">为保证账号安全,须短信验证{{ phone }}</view>
  65. <view class="inp flexB">
  66. <input type="text" placeholder="请输入验证码" maxlength="6" placeholder-style="font-size:28rpx;color:#999"
  67. v-model="oldSms" />
  68. <text @click="getOld">{{ oldDown ? `重新获取(${oldDown}s)` : '获取验证码' }}</text>
  69. </view>
  70. <view class="sub_btn" @click="next">下一步</view>
  71. </view>
  72. <view class="new" v-else>
  73. <input type="text" placeholder="请输入手机号" maxlength="11" placeholderk-style="font-size:28rpx;color:#999"
  74. class="phone_inp" v-model="newPhone" :disabled="isEdit" />
  75. <view class="inp flexB">
  76. <input type="text" placeholder="请输入验证码" maxlength="6" placeholder-style="font-size:28rpx;color:#999"
  77. v-model="newSms" />
  78. <text @click="getNew">{{ newDown ? `重新获取(${newDown}s)` : '获取验证码' }}</text>
  79. </view>
  80. <view class="sub_btn" @click="editPhone">完成</view>
  81. </view>
  82. </view>
  83. <!-- 修改店铺地址 -->
  84. <view class="edit_ads" v-if="statusShow == 3">
  85. <view>
  86. <view class="label">
  87. <text>店铺地址</text>
  88. <text>*</text>
  89. </view>
  90. <picker mode="region" @change="bindRegionChange" :value="location" :custom-item="customItem">
  91. <view class="flexB picker">
  92. <text style="font-size:32rpx;padding-left:15rpx;">{{location?location:'请点击选择店铺地址'}}</text>
  93. <text class="iconfont iconzhcc_xiangxiajiantou"></text>
  94. </view>
  95. </picker>
  96. </view>
  97. <w-picker ref="Selector" mode="region" themeColor="#F76454" @confirm="onConfirm" />
  98. <view>
  99. <view class="label">
  100. <text>店铺详细地址</text>
  101. <text>*</text>
  102. </view>
  103. <view><input type="text" placeholder="请输入详细地址" v-model="adsParams.address"
  104. placeholder-style="color:#999;" /></view>
  105. </view>
  106. <view @click="editAds" class="sub_btn">{{ location ? '确认修改' : '确认添加' }}</view>
  107. </view>
  108. </view>
  109. </template>
  110. <script>
  111. import {
  112. getStoreInfo,
  113. sendSms,
  114. checkPhone,
  115. editPhone,
  116. editName,
  117. editAds
  118. } from '@/apis/shop.js';
  119. export default {
  120. data() {
  121. return {
  122. info: '', //店铺信息
  123. statusShow: 0,
  124. step: 0, //修改手机步骤
  125. name: '', //店铺名称
  126. store_id: '', //店铺id
  127. phone: '', //手机号
  128. oldPhone: '', //旧手机号
  129. oldSms: '', //旧手机短信验证码
  130. oldDown: 0, //手机验证码倒计时
  131. newPhone: '', //新手机号
  132. newSms: '', //新手机短信验证码
  133. newDown: 0, //手机验证码倒计时,
  134. isSend: true, //是否发送
  135. timer: null,
  136. isEdit: false, //是否禁止输入手机号
  137. location: '', //店铺地址,
  138. adsParams: {
  139. province: '',
  140. city: '',
  141. area: '',
  142. address: ''
  143. },
  144. imgUrl: '/static/imgs/shop/upload_wx.png'
  145. };
  146. },
  147. onLoad() {
  148. this.getInfo();
  149. },
  150. methods: {
  151. //选择店铺地址
  152. bindRegionChange(e) {
  153. let ads = e.detail.value;
  154. this.location = `${ads[0]}-${ads[1]}-${ads[2]}`;
  155. this.adsParams.province = ads[0];
  156. this.adsParams.city = ads[1];
  157. this.adsParams.area = ads[2];
  158. },
  159. uploadCode() {
  160. uni.chooseImage({
  161. count: 1, //默认9
  162. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  163. sourceType: ['album'], //从相册选择
  164. success: res => {
  165. // const imgType = ['image/png', 'image/jpg', 'image/jpeg'];
  166. // let type = res.tempFiles[0].type;
  167. // if (imgType.indexOf(type) === -1) {
  168. // uni.showModal({
  169. // content: '图片格式不正确',
  170. // showCancel: false
  171. // });
  172. // return false;
  173. // }
  174. uni.showLoading({
  175. title: '上传中...'
  176. });
  177. uni.uploadFile({
  178. url: `${this.$config.redirect_uri}/api/store_goods/upload_wx_qr_code_img`,
  179. filePath: res.tempFilePaths[0],
  180. name: 'img',
  181. header: {
  182. Authorization: 'Bearer ' + uni.getStorageSync('token')
  183. // Authorization:
  184. // 'Bearer ' +
  185. // 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hcGkuYXBwLmppdXdlaXl1bi5jblwvYXBpXC9sb2dpblwvZ2V0X3VzZXJfb3BlbmlkIiwiaWF0IjoxNjE3MTA1MTI5LCJleHAiOjE2MTc5NjkxMjksIm5iZiI6MTYxNzEwNTEyOSwianRpIjoidElBRHBwakZMUXVkSmtpSiIsInN1YiI6NDk0MjgsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.g8YdgFXY_hzN308um5hWrKf7OPlo5Q9SVgwTjO_8Bdw'
  186. },
  187. success: upload => {
  188. let data = JSON.parse(upload.data);
  189. uni.hideLoading();
  190. if (data.code == 200) {
  191. this.imgUrl = data.data;
  192. uni.showToast({
  193. title: '修改成功'
  194. });
  195. } else {
  196. uni.showModal({
  197. content: data.data || '上传二维码失败,请重试',
  198. showCancel: false
  199. });
  200. }
  201. },
  202. fail: err => {
  203. console.log(33333)
  204. uni.hideLoading();
  205. uni.showModal({
  206. content: '上传二维码失败,请重试',
  207. showCancel: false
  208. });
  209. }
  210. });
  211. }
  212. });
  213. },
  214. //获取旧手机号验证码
  215. getOld() {
  216. let that = this;
  217. if (that.oldDown) {
  218. uni.showModal({
  219. content: '验证码已发送,请稍后重试',
  220. showCancel: false
  221. });
  222. return false;
  223. }
  224. if (!that.oldPhone || that.oldPhone.length != 11) {
  225. uni.showModal({
  226. content: '手机号格式不正确',
  227. showCancel: false
  228. });
  229. return false;
  230. }
  231. sendSms({
  232. phone: that.oldPhone,
  233. type: 'phone'
  234. }).then(res => {
  235. if (res.code == 200) {
  236. uni.showModal({
  237. content: '验证码发送成功',
  238. showCancel: false
  239. });
  240. this.oldDown = 60;
  241. this.timer = setInterval(() => {
  242. this.oldDown--;
  243. if (!this.oldDown) {
  244. this.oldDown = 0;
  245. clearInterval(this.timer);
  246. }
  247. }, 1000);
  248. } else {
  249. uni.showModal({
  250. content: res.data || '获取验证码失败',
  251. showCancel: false
  252. });
  253. return false;
  254. }
  255. });
  256. },
  257. //获取新手机号验证码
  258. getNew() {
  259. let that = this;
  260. if (that.newDown) {
  261. uni.showModal({
  262. content: '验证码已发送,请稍后重试',
  263. showCancel: false
  264. });
  265. return false;
  266. }
  267. if (!that.newPhone || that.newPhone.length != 11) {
  268. uni.showModal({
  269. content: '手机号格式不正确',
  270. showCancel: false
  271. });
  272. return false;
  273. }
  274. sendSms({
  275. phone: that.newPhone,
  276. type: 'phone'
  277. })
  278. .then(res => {
  279. if (res.code == 200) {
  280. this.isEdit = true; //禁止编辑手机号
  281. uni.showModal({
  282. content: '验证码发送成功',
  283. showCancel: false
  284. });
  285. this.newDown = 60;
  286. this.timer = setInterval(() => {
  287. this.newDown--;
  288. if (!this.newDown) {
  289. this.newDown = 0;
  290. clearInterval(this.timer);
  291. }
  292. }, 1000);
  293. } else {
  294. uni.showModal({
  295. content: res.data || '获取验证码失败',
  296. showCancel: false
  297. });
  298. return false;
  299. }
  300. })
  301. .finally(() => {
  302. this.isEdit = false;
  303. });
  304. },
  305. /*修改新手机号*/
  306. editPhone() {
  307. let that = this;
  308. if (!that.newPhone || that.newPhone.length != 11) {
  309. uni.showModal({
  310. content: '手机号格式不正确'
  311. });
  312. return false;
  313. }
  314. if (!that.newSms || that.newSms.length != 6) {
  315. uni.showModal({
  316. content: '验证码格式不正确'
  317. });
  318. return false;
  319. }
  320. if (!that.isSend) return false;
  321. that.isSend = false;
  322. editPhone({
  323. phone: this.newPhone,
  324. phone_code: this.newSms,
  325. store_id: this.store_id
  326. })
  327. .then(res => {
  328. if (res.code == 200) {
  329. uni.showToast({
  330. title: '修改成功'
  331. });
  332. this.statusShow = 0;
  333. this.getInfo();
  334. } else {
  335. uni.showModal({
  336. content: res.data || '修改手机号失败',
  337. showCancel: false
  338. });
  339. if (res.data == '新手机号不能与旧手机号相同') {
  340. this.newDown = 0;
  341. this.newSms = '';
  342. this.isEdit = false;
  343. clearInterval(this.timer);
  344. }
  345. }
  346. })
  347. .catch(e => {})
  348. .finally(() => {
  349. that.isSend = true;
  350. this.isEdit = false;
  351. });
  352. },
  353. /*修改地址*/
  354. editAds() {
  355. if (!this.location) {
  356. uni.showModal({
  357. content: '请选择店铺地址',
  358. showCancel: false
  359. });
  360. return false;
  361. }
  362. if (!this.adsParams.address) {
  363. uni.showModal({
  364. content: '请填写店铺详细地址',
  365. showCancel: false
  366. });
  367. return false;
  368. }
  369. let params = this.adsParams;
  370. editAds(params).then(res => {
  371. if (res.code == 200) {
  372. this.statusShow = 0;
  373. this.getInfo();
  374. uni.showToast({
  375. title: '修改成功'
  376. });
  377. } else {
  378. uni.showModal({
  379. content: res.msg || '修改店铺地址失败',
  380. showCancel: false
  381. });
  382. }
  383. });
  384. },
  385. /*验证手机号下一步*/
  386. next() {
  387. let that = this;
  388. if (!that.oldSms || that.oldSms.length != 6) {
  389. uni.showModal({
  390. content: '验证码格式不正确',
  391. showCancel: false
  392. });
  393. return false;
  394. }
  395. if (!that.isSend) return false;
  396. that.isSend = false;
  397. checkPhone({
  398. phone: that.oldPhone,
  399. phone_code: that.oldSms
  400. })
  401. .then(res => {
  402. if (res.code == 200) {
  403. that.step = 1;
  404. uni.setNavigationBarTitle({
  405. title: '绑定新手机号'
  406. });
  407. } else {
  408. uni.showModal({
  409. content: res.data,
  410. showCancel: false
  411. });
  412. }
  413. })
  414. .catch(e => {})
  415. .finally(() => {
  416. that.isSend = true;
  417. });
  418. },
  419. //修改店铺名称
  420. finish() {
  421. if (!this.name) {
  422. uni.showModal({
  423. content: '店铺名称不能为空',
  424. showCancel: false
  425. });
  426. return false;
  427. }
  428. editName({
  429. name: this.name,
  430. store_id: this.info.id
  431. }).then(res => {
  432. if (res.code == 200) {
  433. uni.showToast({
  434. title: '修改成功!',
  435. duration: 3000
  436. });
  437. this.statusShow = 0;
  438. this.getInfo();
  439. } else {
  440. uni.showModal({
  441. content: res.data || '修改失败',
  442. showCancel: false
  443. });
  444. }
  445. });
  446. },
  447. /*获取店铺信息*/
  448. getInfo() {
  449. uni.showLoading({
  450. title: '加载中...'
  451. });
  452. getStoreInfo()
  453. .then(res => {
  454. if (res.code == 200) {
  455. this.info = res.data.store;
  456. const {
  457. province,
  458. city,
  459. area,
  460. address,
  461. qr_code
  462. } = res.data.store;
  463. this.imgUrl = qr_code;
  464. this.adsParams.province = province;
  465. this.adsParams.city = city;
  466. this.adsParams.area = area;
  467. this.adsParams.address = address ? address : '';
  468. if (province && city && area) {
  469. this.location = `${province}-${city}-${area}`;
  470. }
  471. this.phone = this.info.phone.substr(0, 3) + '****' + this.info.phone.substr(7);
  472. this.oldPhone = this.info.phone;
  473. this.$forceUpdate();
  474. } else {
  475. uni.showModal({
  476. content: res.data || '获取店铺信息失败',
  477. showCancel: false
  478. });
  479. }
  480. uni.hideLoading();
  481. })
  482. .catch(err => {
  483. uni.hideLoading();
  484. });
  485. },
  486. /*编辑名称或者手机号*/
  487. edit(type) {
  488. this.statusShow = type;
  489. this.name = this.info.name;
  490. },
  491. skipAuth(type) {
  492. let url = '';
  493. url = type == 0 ? '../real-name-auth/real-name-auth' : '../auth-center/auth-center';
  494. uni.navigateTo({
  495. url
  496. });
  497. }
  498. }
  499. };
  500. </script>
  501. <style lang="scss">
  502. .shop_info {
  503. width: 100%;
  504. min-height: 100%;
  505. background-color: #fff;
  506. }
  507. .edit_name {
  508. .name {
  509. .hint {
  510. font-size: 28rpx;
  511. color: $base-color;
  512. margin-left: 16rpx;
  513. padding: 30rpx 0 20rpx;
  514. }
  515. input {
  516. width: 100%;
  517. background: #f9f9fb;
  518. height: 98rpx;
  519. padding-left: 20rpx;
  520. }
  521. .notice {
  522. width: 690rpx;
  523. margin: 0 auto 162rpx;
  524. view {
  525. padding-top: 5rpx;
  526. }
  527. view:first-child {
  528. font-size: 32rpx;
  529. font-weight: bold;
  530. padding: 40rpx 0 20rpx;
  531. }
  532. }
  533. }
  534. }
  535. .edit_phone {
  536. .phone_inp,
  537. .inp {
  538. width: 580rpx;
  539. height: 88rpx;
  540. background: #f8f8f8;
  541. padding: 0 30rpx;
  542. border-radius: 44rpx;
  543. box-sizing: border-box;
  544. }
  545. .inp {
  546. margin-bottom: 78rpx;
  547. input {
  548. width: 60%;
  549. height: 90%;
  550. }
  551. }
  552. .phone_inp {
  553. margin: 94rpx 0 30rpx;
  554. }
  555. .old {
  556. .hint {
  557. margin: 94rpx 0 30rpx;
  558. }
  559. }
  560. }
  561. .edit_ads {
  562. width: 690rpx;
  563. margin: 30rpx auto 0;
  564. .sub_btn {
  565. margin-top: 50rpx;
  566. }
  567. .label {
  568. font-size: 32rpx;
  569. padding: 10rpx 0;
  570. color: #333;
  571. font-weight: 600;
  572. text:last-child {
  573. color: #f00;
  574. margin-left: 4rpx;
  575. font-size: 45rpx;
  576. }
  577. }
  578. input,
  579. .picker {
  580. height: 96rpx;
  581. line-height: 96rpx;
  582. background: #f8f8f8;
  583. border-radius: 8rpx;
  584. }
  585. .picker {
  586. padding-right: 30rpx;
  587. input {
  588. width: 90%;
  589. }
  590. }
  591. input {
  592. font-size: 32rpx;
  593. padding-left: 30rpx;
  594. }
  595. }
  596. .title {
  597. color: #999;
  598. font-size: 28rpx;
  599. padding: 30rpx 0;
  600. }
  601. .iconfont {
  602. font-size: 40rpx;
  603. color: #999;
  604. }
  605. .label {
  606. font-size: 28rpx;
  607. }
  608. .auth,
  609. .base_info {
  610. padding: 0 30rpx;
  611. box-sizing: border-box;
  612. }
  613. .base_info {
  614. .info {
  615. .wx_img {
  616. width: 300rpx;
  617. height: 300rpx;
  618. }
  619. >view {
  620. margin-bottom: 30rpx;
  621. .inp {
  622. width: 75%;
  623. min-height: 72rpx;
  624. background: #f8f8f8;
  625. border-radius: 8rpx;
  626. padding: 0 15rpx;
  627. box-sizing: border-box;
  628. }
  629. input,
  630. textarea {
  631. width: 75%;
  632. font-size: 32rpx;
  633. }
  634. .iconfont {
  635. font-size: 35rpx;
  636. color: #999;
  637. }
  638. }
  639. image {
  640. width: 68rpx;
  641. height: 68rpx;
  642. border-radius: 8rpx;
  643. margin-right: 20rpx;
  644. }
  645. .code_hint {
  646. color: $base-color;
  647. font-size: 28rpx;
  648. margin-top: 30rpx;
  649. }
  650. }
  651. .upload {
  652. .up_title {
  653. font-size: 36rpx;
  654. font-weight: bold;
  655. }
  656. .wx_icon {
  657. width: 250rpx;
  658. height: 250rpx;
  659. margin: 40rpx 0;
  660. }
  661. }
  662. }
  663. .block {
  664. width: 100%;
  665. height: 20rpx;
  666. background: #f9f9fb;
  667. }
  668. .auth {
  669. .auth_con {
  670. >view {
  671. margin-top: 30rpx;
  672. }
  673. .iconrenzheng {
  674. color: $base-color;
  675. font-size: 45rpx;
  676. vertical-align: middle;
  677. margin-right: 5rpx;
  678. }
  679. .iconiconfontjiantou2 {
  680. font-size: 35rpx;
  681. vertical-align: -2rpx;
  682. }
  683. }
  684. }
  685. </style>