index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. <template>
  2. <view :style="viewColor">
  3. <view :style="{ 'background-image': `linear-gradient(0deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) 40%),url(${store.mer_banner})` }" class="store-detail">
  4. <view class="section head">
  5. <image :src="store.mer_avatar"></image>
  6. <view class="text-wrap">
  7. <view class="name line1">
  8. <text class="name_store">{{ store.mer_name }}</text>
  9. <image v-if="margin_ico_switch==1 && margin_ico && store.is_margin == 10" :src="margin_ico" class="store-margin"></image>
  10. <text v-if="store.type_name" class="font-bg-red ml8">{{ store.type_name }}</text>
  11. <text v-else-if="store.is_trader" class="font-bg-red ml8">自营</text>
  12. </view>
  13. <view class="fans">{{ store.care_count < 10000 ? store.care_count : (store.care_count / 10000).toFixed(2) + '万' }}人关注</view>
  14. </view>
  15. <button :class="{ followed: store.care }" hover-class="none" @click="followToggle">
  16. <text v-show="!store.care" class="iconfont icon-guanzhu"></text>
  17. {{ store.care ? '已关注' : '关注' }}
  18. </button>
  19. </view>
  20. <view class="section wrap">
  21. <view class="name">店铺评级</view>
  22. <view class="score-wrap">
  23. <view class="star" :class="'star' + keyColor"><view :style="{ width: `${star.toFixed(2)}%`, backgroundImage: `url(${domain}/static/diy/score1${keyColor}.png)` }"></view></view>
  24. <view>{{ score.toFixed(1) }}</view>
  25. </view>
  26. </view>
  27. <view class="section wrap" @click="popupShow = true">
  28. <view class="name">店铺二维码</view>
  29. <view><text class="iconfont icon-erweima1"></text></view>
  30. </view>
  31. <navigator v-if="store.isset_certificate" :url="`/pages/store/qualifications/index?mer_id=${store.mer_id}&uid=${this.uid}&storeName=${store.mer_name}`" class="section wrap">
  32. <view class="name">店铺资质信息</view>
  33. <view><text class="iconfont">&#xe743;</text></view>
  34. </navigator>
  35. <view v-if="store.services_type == 1" class="section wrap" @click="call(1)">
  36. <view class="name">联系客服</view>
  37. <view><text class="iconfont icon-kefu1"></text></view>
  38. </view>
  39. <view v-else-if="store.services_type == 0" @click="goChat" class="section wrap">
  40. <view class="name">联系客服</view>
  41. <view><text class="iconfont icon-kefu1"></text></view>
  42. </view>
  43. <view v-else class="section wrap" @click="call(0)">
  44. <view class="name">联系客服</view>
  45. <view><text class="iconfont icon-kefu1"></text></view>
  46. </view>
  47. <view class="section info">
  48. <view class="item very">
  49. <view class="name">店铺简介</view>
  50. <view class="value">{{ store.mer_info }}</view>
  51. </view>
  52. <view class="item very">
  53. <view class="name">店铺地址</view>
  54. <view class="value">{{ store.mer_address }}</view>
  55. <view v-if="store.lat && store.long && mer_location == 1" class="iconfont icon-dingwei" @click="showMaoLocation(store.lat, store.long)"></view>
  56. </view>
  57. <view v-if="store.service_phone" class="item">
  58. <view class="name">联系电话</view>
  59. <view class="value">{{ store.service_phone }}</view>
  60. </view>
  61. <view class="item">
  62. <view class="name">开店时间</view>
  63. <view class="value">{{ store.create_time | dateFormat }}</view>
  64. </view>
  65. </view>
  66. <view :class="{ mask: popupShow }" @click="popupShow = false"></view>
  67. <view :class="{ 'popup-active': popupShow }" class="popup-qrcode">
  68. <view class="name">{{ store.mer_name }}</view>
  69. <view class="info">保存二维码可分享店铺给好友哦~</view>
  70. <!-- #ifndef MP -->
  71. <image :src="storeCode"></image>
  72. <!-- #endif -->
  73. <!-- #ifdef MP -->
  74. <image :src="storeCode" @longpress="savePosterPath(storeCode)"></image>
  75. <!-- #endif -->
  76. </view>
  77. </view>
  78. </view>
  79. </template>
  80. <script>
  81. // +----------------------------------------------------------------------
  82. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  83. // +----------------------------------------------------------------------
  84. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  85. // +----------------------------------------------------------------------
  86. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  87. // +----------------------------------------------------------------------
  88. // | Author: CRMEB Team <admin@crmeb.com>
  89. // +----------------------------------------------------------------------
  90. import { mapGetters } from 'vuex';
  91. import { configMap } from "@/utils";
  92. import { getStoreDetail, followStore, unfollowStore, merchantQrcode } from '@/api/store.js';
  93. import { HTTP_REQUEST_URL } from '@/config/app';
  94. import { toLogin } from '@/libs/login.js';
  95. let app = getApp();
  96. export default {
  97. computed: {
  98. ...configMap({margin_ico_switch: 0,margin_ico: ''}, mapGetters(['isLogin','uid','viewColor','keyColor'])),
  99. },
  100. filters: {
  101. dateFormat: function(value) {
  102. if (!value) {
  103. return '';
  104. }
  105. return value.split(' ')[0];
  106. }
  107. },
  108. data() {
  109. return {
  110. domain: HTTP_REQUEST_URL,
  111. id: 0,
  112. store: {},
  113. score: 0,
  114. star: 0,
  115. popupShow: false,
  116. storeCode: '',
  117. openSettingBtnHidden: true, //是否授权
  118. mer_location: '',
  119. };
  120. },
  121. onLoad: function(options) {
  122. uni.getStorage({
  123. key: 'GLOBAL_DATA',
  124. success: res => {
  125. this.mer_location = res.data.mer_location;
  126. }
  127. });
  128. this.id = options.mer_id || options.id;
  129. this.getStore();
  130. this.getStoreCode();
  131. },
  132. onReady: function() {},
  133. mounted: function() {},
  134. methods: {
  135. call: function(){
  136. let that = this;
  137. if(that.store.service_phone){
  138. uni.showModal({
  139. title: '提示',
  140. content: '暂无在线客服,确定拨打客服电话:'+that.store.service_phone+'吗?',
  141. success: function(res) {
  142. if (res.confirm) {
  143. uni.makePhoneCall({
  144. phoneNumber: that.store.service_phone,
  145. });
  146. }
  147. }
  148. })
  149. }else{
  150. return that.$util.Tips({
  151. title: '暂无可用客服'
  152. })
  153. }
  154. },
  155. getStore: function() {
  156. getStoreDetail(this.id).then(res => {
  157. let store = res.data;
  158. this.store = store;
  159. this.score = (parseFloat(store.postage_score) + parseFloat(store.product_score) + parseFloat(store.service_score)) / 3;
  160. this.star = (this.score / 5) * 100;
  161. });
  162. },
  163. // 联系客服
  164. goChat(){
  165. if(this.isLogin){
  166. uni.navigateTo({
  167. url: `/pages/chat/customer_list/chat?mer_id=${this.store.mer_id}&uid=${this.uid}`
  168. })
  169. }else{
  170. toLogin()
  171. }
  172. },
  173. follow: function() {
  174. followStore(this.id).then(res => {
  175. if (res.status === 200) {
  176. this.store.care = true;
  177. }
  178. this.$util.Tips({
  179. title: res.message
  180. });
  181. });
  182. },
  183. //查看地图
  184. showMaoLocation(lat, long) {
  185. console.log(lat, long);
  186. if (!lat || !long)
  187. return this.$util.Tips({
  188. title: '请设置允许商城访问您的位置!'
  189. });
  190. //#ifdef H5
  191. if (this.$wechat.isWeixin() === true) {
  192. this.$wechat
  193. .seeLocation({
  194. latitude: Number(lat),
  195. longitude: Number(long),
  196. name: this.store.mer_name,
  197. address: this.store.mer_address ? this.store.mer_address : ''
  198. })
  199. .then(res => {
  200. console.log('success');
  201. });
  202. } else {
  203. //#endif
  204. uni.openLocation({
  205. latitude: parseFloat(lat),
  206. longitude: parseFloat(long),
  207. scale: 8,
  208. geocode: true,
  209. name: this.store.mer_name,
  210. address: this.store.mer_address ? this.store.mer_address : '',
  211. success: function(res) {
  212. console.log(res);
  213. }
  214. });
  215. // #ifdef H5
  216. }
  217. //#endif
  218. },
  219. unfollow: function() {
  220. unfollowStore(this.id).then(res => {
  221. if (res.status === 200) {
  222. this.store.care = false;
  223. }
  224. this.$util.Tips({
  225. title: res.message
  226. });
  227. });
  228. },
  229. followToggle: function() {
  230. this.store.care ? this.unfollow() : this.follow();
  231. },
  232. // 店铺二维码
  233. getStoreCode() {
  234. let params = {};
  235. // #ifdef MP
  236. params = {
  237. type: 'routine'
  238. };
  239. //#endif
  240. merchantQrcode(this.id, params)
  241. .then(res => {
  242. this.storeCode = res.data.url;
  243. })
  244. .catch(err => {});
  245. },
  246. // #ifdef MP
  247. // 小程序保存图片
  248. savePosterPath(url) {
  249. uni.downloadFile({
  250. url,
  251. success: resFile => {
  252. if (resFile.statusCode === 200) {
  253. uni.getSetting({
  254. success: res => {
  255. if (!res.authSetting['scope.writePhotosAlbum']) {
  256. uni.authorize({
  257. scope: 'scope.writePhotosAlbum',
  258. success: () => {
  259. uni.saveImageToPhotosAlbum({
  260. filePath: resFile.tempFilePath,
  261. success: res => {
  262. return uni.showToast({
  263. title: '保存成功!'
  264. });
  265. },
  266. fail: res => {
  267. return uni.showToast({
  268. title: res.errMsg
  269. });
  270. },
  271. complete: res => {}
  272. });
  273. },
  274. fail: () => {
  275. uni.showModal({
  276. title: '您已拒绝获取相册权限',
  277. content: '是否进入权限管理,调整授权?',
  278. success: res => {
  279. if (res.confirm) {
  280. uni.openSetting({
  281. success: res => {
  282. console.log(res.authSetting);
  283. }
  284. });
  285. } else if (res.cancel) {
  286. return uni.showToast({
  287. title: '已取消!'
  288. });
  289. }
  290. }
  291. });
  292. }
  293. });
  294. } else {
  295. uni.saveImageToPhotosAlbum({
  296. filePath: resFile.tempFilePath,
  297. success: res => {
  298. return uni.showToast({
  299. title: '保存成功!'
  300. });
  301. },
  302. fail: res => {
  303. return uni.showToast({
  304. title: res.errMsg
  305. });
  306. },
  307. complete: res => {}
  308. });
  309. }
  310. },
  311. fail: res => {}
  312. });
  313. } else {
  314. return uni.showToast({
  315. title: resFile.errMsg
  316. });
  317. }
  318. },
  319. fail: res => {
  320. return uni.showToast({
  321. title: res.errMsg
  322. });
  323. }
  324. });
  325. }
  326. // #endif
  327. }
  328. };
  329. </script>
  330. <style lang="scss" scoped>
  331. .font-bg-red {
  332. display: flex;
  333. align-items: center;
  334. background: var(--view-theme);
  335. border-color: var(--view-theme);
  336. color: #fff;
  337. font-size: 20rpx;
  338. text-align: center;
  339. line-height: 30rpx;
  340. height: 28rpx;
  341. border-radius: 5rpx;
  342. margin-right: 8rpx;
  343. &.ml8 {
  344. margin-left: 8rpx;
  345. margin-right: 0;
  346. }
  347. }
  348. .store-detail {
  349. padding-top: 80rpx;
  350. padding-right: 20rpx;
  351. padding-left: 20rpx;
  352. background: left top/750rpx 360rpx no-repeat fixed;
  353. .section {
  354. border-radius: 10rpx;
  355. margin-bottom: 20rpx;
  356. background-color: #ffffff;
  357. }
  358. .head {
  359. display: flex;
  360. align-items: center;
  361. padding: 20rpx;
  362. image {
  363. width: 90rpx;
  364. height: 90rpx;
  365. border-radius: 6rpx;
  366. }
  367. .text-wrap {
  368. flex: 1;
  369. min-width: 0;
  370. margin-right: 20rpx;
  371. margin-left: 20rpx;
  372. line-height: 1;
  373. .store-margin{
  374. width: 28rpx;
  375. height: 30rpx;
  376. margin-left: 10rpx;
  377. }
  378. .name {
  379. display: flex;
  380. align-items: center;
  381. font-weight: bold;
  382. font-size: 28rpx;
  383. color: #282828;
  384. .name_store {
  385. display: inline-block;
  386. overflow: hidden;
  387. white-space: nowrap;
  388. text-overflow: ellipsis;
  389. max-width: 140px;
  390. }
  391. }
  392. .fans {
  393. margin-top: 15rpx;
  394. font-weight: 500;
  395. font-size: 22rpx;
  396. color: #666666;
  397. }
  398. }
  399. button {
  400. display: flex;
  401. justify-content: center;
  402. align-items: center;
  403. width: 113rpx;
  404. height: 48rpx;
  405. border-radius: 24rpx;
  406. background-image: linear-gradient(-90deg, var(--view-bntColor21) 0%, var(--view-bntColor22) 100%);
  407. font-weight: 500;
  408. font-size: 22rpx;
  409. color: #ffffff;
  410. .iconfont {
  411. margin-right: 6rpx;
  412. font-size: 22rpx;
  413. }
  414. }
  415. .followed {
  416. border: 1px solid #bfbfbf;
  417. background: none;
  418. color: #999999;
  419. }
  420. }
  421. .wrap {
  422. display: flex;
  423. align-items: center;
  424. padding: 32rpx 20rpx;
  425. .name {
  426. flex: 1;
  427. min-width: 0;
  428. font-weight: 400;
  429. font-size: 28rpx;
  430. color: #282828;
  431. }
  432. .score-wrap {
  433. display: flex;
  434. align-items: center;
  435. font-weight: 500;
  436. font-size: 28rpx;
  437. color: var(--view-theme);
  438. .star {
  439. position: relative;
  440. width: 111rpx;
  441. height: 19rpx;
  442. margin-right: 10rpx;
  443. background: url(../../columnGoods/images/star.png) left top/100% 100% no-repeat;
  444. overflow: hidden;
  445. view {
  446. position: absolute;
  447. top: 0;
  448. left: 0;
  449. height: 100%;
  450. background: url(../../columnGoods/images/star_active.png) left top/111rpx 19rpx no-repeat;
  451. }
  452. }
  453. }
  454. .iconfont {
  455. font-size: 36rpx;
  456. }
  457. .icon-pingfen {
  458. margin-right: 6rpx;
  459. font-size: 23rpx;
  460. color: #666666;
  461. }
  462. .active {
  463. color: $theme-color;
  464. }
  465. }
  466. .info {
  467. .item {
  468. display: flex;
  469. align-items: center;
  470. padding: 30rpx 20rpx;
  471. border: 1px solid #f5f5f5;
  472. font-weight: normal;
  473. font-size: 28rpx;
  474. line-height: 30rpx;
  475. color: #282828;
  476. .name {
  477. margin-right: 18rpx;
  478. }
  479. .value {
  480. flex: 1;
  481. min-width: 0;
  482. }
  483. }
  484. .very {
  485. .name {
  486. align-self: flex-start;
  487. }
  488. }
  489. }
  490. .popup-qrcode {
  491. position: fixed;
  492. top: 50%;
  493. left: 50%;
  494. z-index: 99;
  495. width: 544rpx;
  496. padding-top: 48rpx;
  497. padding-bottom: 36rpx;
  498. border-radius: 24rpx;
  499. background-color: #ffffff;
  500. transform: translate(-50%, -50%) scale(0);
  501. opacity: 0;
  502. transition: 0.3s;
  503. line-height: 1;
  504. text-align: center;
  505. color: #282828;
  506. .name {
  507. max-width: 90%;
  508. margin-right: auto;
  509. margin-left: auto;
  510. font-weight: bold;
  511. font-size: 32rpx;
  512. }
  513. .info {
  514. margin-top: 24rpx;
  515. font-weight: 500;
  516. font-size: 24rpx;
  517. }
  518. image {
  519. width: 384rpx;
  520. height: 384rpx;
  521. margin-top: 18rpx;
  522. }
  523. }
  524. .popup-active {
  525. transform: translate(-50%, -50%) scale(1);
  526. opacity: 1;
  527. }
  528. }
  529. </style>