index.vue 13 KB

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