index.vue 11 KB

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