index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <view v-if="isShowPage">
  3. <view class="banner">
  4. <image :src="merchant.mainGraph ? merchant.mainGraph : picUrlss+'scrm/md_default.jpg'"></image>
  5. </view>
  6. <view class="con">
  7. <view class="info">
  8. <view class="title ddflex">
  9. <view class="name fflex">{{merchant.title}}</view>
  10. <navigator url="/merchant/nearby/nearby" hover-class="none" class="change ddflex">切换门店<image
  11. src="../../static/pages/images/rico.png"></image>
  12. </navigator>
  13. </view>
  14. <view class="mai">{{merchant.buyPerson}}位朋友买过 ·
  15. {{merchant.range ? merchant.mDistance < 1000 ? merchant.mDistance+'m' : merchant.range+'km' : ''}}
  16. </view>
  17. <view class="time ddflex">
  18. <image :src="picUrlss+'scrm/md_yysj.png'" class="info-img"></image>营业中 · {{merchant.businessTime}}
  19. </view>
  20. <view class="ddflex">
  21. <view class="addr ddflex fflex">
  22. <image :src="picUrlss+'scrm/md_dz.png'" class="info-img"></image>
  23. <view class="fflex">{{merchant.address}}</view>
  24. </view>
  25. <view class="tel" @click="callPhone()">
  26. <image :src="picUrlss+'scrm/md_dh.png'">
  27. </view>
  28. </view>
  29. </view>
  30. <view class="opt ddflex">
  31. <view class="li ddflex" @click="jumpUrl('/payment/payment/payment?merchantId='+merchant.id)">
  32. <image :src="picUrlss+'scrm/md_md.png'"></image>买单
  33. </view>
  34. <view class="li ddflex" @click="jumpUrl('/product/coupon/coupon')">
  35. <image :src="picUrlss+'scrm/md_yhq.png'"></image>优惠券
  36. </view>
  37. <view class="li ddflex" @click="jumpUrl('/mine/vip/vip')">
  38. <image :src="picUrlss+'scrm/md_hy.png'"></image>会员
  39. </view>
  40. </view>
  41. </view>
  42. <block v-if="recommendProduct.length>0">
  43. <navigator url="/product/list/list?attr=Recommend&title=推荐产品" hover-class="none" class="tits ddflex">推荐产品
  44. <image src="../../static/pages/images/more.png" class="rico"></image>
  45. </navigator>
  46. <view class="pro ddflex">
  47. <view class="li" v-for="(item,index) in recommendProduct" :key="index"
  48. @click="jumpUrl('/product/detail/detail?id=' + item.id)">
  49. <image :src="item.pic" mode="aspectFill" class="pro-img"></image>
  50. <view class="pro-info">
  51. <view class="pro-tit tover">{{item.title}}</view>
  52. <view class="money"><text>¥</text>{{item.salePrice}}</view>
  53. </view>
  54. </view>
  55. </view>
  56. </block>
  57. <block v-if="serviceList.length>0">
  58. <navigator url="/product/list/list?productForm=2&title=服务项目" hover-class="none" class="tits ddflex">服务项目
  59. <image src="../../static/pages/images/more.png" class="rico"></image>
  60. </navigator>
  61. <view class="pro ddflex">
  62. <view class="li" v-for="(item,index) in serviceList" :key="index"
  63. @click="jumpUrl('/product/detail/detail?id=' + item.id)" v-if="index < 3">
  64. <image :src="item.pic" mode="aspectFill" class="pro-img"></image>
  65. <view class="pro-info">
  66. <view class="pro-tit tover">{{item.title}}</view>
  67. <view class="money"><text>¥</text>{{item.salePrice}}</view>
  68. </view>
  69. </view>
  70. </view>
  71. </block>
  72. <footer-copyright></footer-copyright>
  73. <foot channel="merchant" :isUpdate="isUpdate"></foot>
  74. <!-- #ifdef H5 -->
  75. <wx-share ref="wxshare" />
  76. <!-- #endif -->
  77. </view>
  78. </template>
  79. <script>
  80. //index.js
  81. //获取应用实例
  82. const app = getApp();
  83. const req = require('../../utils/request.js');
  84. const api = require('../../utils/api.js');
  85. const utils = require('../../utils/util.js');
  86. const mes = require('../../utils/requestmessage.js');
  87. const route = require('../../utils/route');
  88. const QQMapWX = require("../../utils/qqmap.js");
  89. import foot from '../../components/nav-bar/index';
  90. import footerCopyright from '../../components/footer-copyright/footer-copyright';
  91. export default {
  92. data() {
  93. return {
  94. picUrlss: req.public.picUrls,
  95. query: '',
  96. isShowPage: false,
  97. isUpdate: false, // 是否更新消息
  98. systems: {},
  99. about: '',
  100. merchant: '',
  101. recommendProduct: [],
  102. serviceList: []
  103. };
  104. },
  105. components: {
  106. foot,
  107. footerCopyright,
  108. },
  109. props: {},
  110. onLoad: async function(options) {
  111. if (options.appId) req.setStorage('appId', options.appId);
  112. QQMapWX.initMap(req.public.mapLBSKEY);
  113. req.getLocation(res => {
  114. const to = {
  115. latitude: res.latitude,
  116. longitude: res.longitude
  117. };
  118. QQMapWX.reverseGeocoder(to, resp => {});
  119. });
  120. },
  121. async onShow() {
  122. let _ts = this;
  123. await this.getConfig().then(res => {
  124. // console.log("debug1", res);
  125. _ts.getMerchant();
  126. });
  127. await this.getProduct()
  128. await this.getService()
  129. },
  130. onUnload() {},
  131. onHide() {},
  132. onShareAppMessage: function() {
  133. return this.onShareMessage();
  134. },
  135. onShareTimeline() {
  136. return {
  137. title: this.getShareTitle(),
  138. query: this.getSharePath()
  139. };
  140. },
  141. onReachBottom() {},
  142. onReady() {
  143. // #ifdef H5
  144. var that = this;
  145. //初始化分享内容
  146. setTimeout(function() {
  147. var shareContent = that.onShareMessage();
  148. if (shareContent) {
  149. shareContent.path = window.location.origin + shareContent.path;
  150. }
  151. console.log('分享内容》》》》》', shareContent);
  152. that.$refs.wxshare.init(shareContent);
  153. }, 4 * 1000);
  154. // #endif
  155. },
  156. methods: {
  157. onShareMessage() {
  158. return {
  159. title: this.getShareTitle(),
  160. path: this.getSharePath()
  161. };
  162. },
  163. getSharePath() {
  164. let path = '';
  165. let isSolution = '';
  166. // #ifndef H5
  167. isSolution = req.env[req.env.NODE_ENV].isSolution;
  168. // #endif
  169. // #ifdef H5
  170. isSolution = false;
  171. // #endif
  172. let userInfo = req.getStorage('userInfo');
  173. if (isSolution) {
  174. path = '/share/home/index?appId=' + req.getStorage('appId') + '&userId=' + userInfo.id;
  175. } else {
  176. path = '/pages/merchant/index?isShare=' + true + '&appId=' + req.getStorage('appId');
  177. if (userInfo) {
  178. path += '&userId=' + userInfo.id;
  179. }
  180. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  181. path += '&merchantId=' + req.getStorage('MERCHANT').id;
  182. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  183. path += '&shopId=' + req.getStorage('smallShop').id;
  184. }
  185. }
  186. }
  187. return path;
  188. },
  189. getShareTitle() {
  190. let title = '';
  191. if (this.merchant && this.merchant.title && this.merchant.title != '默认门店') {
  192. title = this.merchant.title;
  193. } else {
  194. title = this.about.CONFIG_PROJECT_TITLE;
  195. }
  196. return (req.excludeSpecial(req.getStorage('userInfo').nickName) ? req.excludeSpecial(req.getStorage(
  197. 'userInfo').nickName) : '') + '为你推荐' + title;
  198. },
  199. getConfig() {
  200. var _this = this;
  201. return new Promise((res, rej) => {
  202. req.g('/api/config', data => {
  203. req.setStorage('configRes', JSON.stringify(data));
  204. this.about = data;
  205. req.setStorage('appName', data['CONFIG_PROJECT_TITLE']);
  206. req.setStorage('productDiy', data['Product_Foot-Diy']);
  207. res(data);
  208. }, true);
  209. });
  210. },
  211. getMerchant() {
  212. let _ts = this;
  213. return new Promise((resolve, reject) => {
  214. api.getMerchant(_ts.query, req, data => {
  215. console.log('===', data)
  216. if (data == 1) {
  217. uni.showModal({
  218. title: '温馨提示',
  219. content: '获取定位失败,请前往设置打开定位权限',
  220. showCancel: false,
  221. success(res) {
  222. if (res.confirm) {
  223. // console.log('用户点击确定');
  224. uni.openSetting({
  225. success(res) {
  226. console.log(res
  227. .authSetting); // res.authSetting = {
  228. }
  229. });
  230. }
  231. }
  232. });
  233. } else {
  234. // _ts.merchant = data;
  235. req.getRequest('/api/merchant/detail', {
  236. id: data.id
  237. }, res => {
  238. _ts.merchant = res
  239. })
  240. _ts.isShowPage = true;
  241. }
  242. resolve();
  243. });
  244. });
  245. },
  246. callPhone() {
  247. uni.makePhoneCall({
  248. phoneNumber: this.merchant.phone
  249. })
  250. },
  251. getProduct() {
  252. let form = {
  253. page: 1,
  254. limit: 3,
  255. merchantId: this.merchant.id,
  256. attr: 'Recommend'
  257. }
  258. return new Promise((resolve, reject) => {
  259. req.getRequest('/api/product/list', form, data => {
  260. this.recommendProduct = data;
  261. resolve();
  262. })
  263. })
  264. },
  265. getService() {
  266. let form = {
  267. page: 1,
  268. limit: 3,
  269. merchantId: this.merchant.id,
  270. productForm: 2
  271. }
  272. return new Promise((resolve, reject) => {
  273. req.getRequest('/api/product/list', form, data => {
  274. this.serviceList = data;
  275. resolve();
  276. })
  277. })
  278. },
  279. jumpUrl(url) {
  280. if (req.isLogin(true)) {
  281. uni.navigateTo({
  282. url: url
  283. })
  284. }
  285. }
  286. },
  287. mounted() {
  288. const systemInfo = uni.getSystemInfoSync();
  289. // px转换到rpx的比例
  290. let pxToRpxScale = 750 / systemInfo.windowWidth;
  291. let systems = {
  292. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  293. navigationHeight: 44 * pxToRpxScale // 导航栏的高度
  294. };
  295. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  296. this.systems = systems;
  297. },
  298. };
  299. </script>
  300. <style>
  301. @import './index.css';
  302. </style>