detail.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852
  1. <template>
  2. <view v-if="allShow">
  3. <!--pages/detail/detail.wxml-->
  4. <view class="banner">
  5. <swiper class="swiper" @change="swiperChange" :current="current" autoplay="true" circular="true"
  6. duration="1000">
  7. <block v-for="(item, index) in product.images" :key="index">
  8. <swiper-item autoplay="true">
  9. <image :src="item + '?x-oss-process=style/w750-auto'" mode="aspectFit"></image>
  10. </swiper-item>
  11. </block>
  12. </swiper>
  13. <view class="dots dflex">
  14. <block v-for="(item, index) in product.images" :key="index">
  15. <view :class="'dot ' + (index == swiperCurrent ? ' active' : '')" :data-current="index"
  16. @tap="dotEvent"></view>
  17. </block>
  18. </view>
  19. </view>
  20. <!-- <view bindtap="saoma">扫码</view> -->
  21. <!-- <view class="notification_bar" wx:if="{{isNotice}}">
  22. <swiper class="swiper_container" vertical="true" autoplay="true" circular="false" duration="1000" interval="5000" easing-function="easeInOutCubic" class="bar_box dflex">
  23. <swiper-item class="bar_con dflex" wx:for="{{contentList}}" wx:key="item">
  24. <view class="bar dflex">
  25. <image class="bar_left" src="{{item.pic}}" />
  26. <text class="bar_text">最新订单来自</text>
  27. <text class="bar_text">{{item.name}},</text>
  28. <text class="bar_text">{{item.time}}</text>
  29. </view>
  30. </swiper-item>
  31. </swiper>
  32. </view> -->
  33. <view class="info bgfff">
  34. <view class="infos dflex">
  35. <view class="price dflex" v-if="product.mode==2">
  36. <text>{{product.integral?product.integral:'0'}}积分</text>
  37. <text class="money" v-if="product.salePrice">+¥{{product.salePrice?product.salePrice:'0'}}</text>
  38. <text class="origin"
  39. v-if="product.salePrice == product.actualPrice && product.marketPrice > 0">¥{{product.marketPrice}}</text>
  40. </view>
  41. <view class=" sellStock" v-if="product.sellStock>0">销量:<text>{{product.sellStock}}</text></view>
  42. <view class="share" @tap="showShare">
  43. <image src="/static/pages/images/fxico.png"></image>分享
  44. </view>
  45. </view>
  46. <view class="title">
  47. <image src="/static/pages/images/jishida.png" class="tag"
  48. v-if="product.isTimely === 1&&merchant.isDefault!=1"></image>
  49. <image src="/product/static/product/image/overseasPurchase.png" class="tag" v-if="product.isOtc===5">
  50. </image>
  51. {{product.title}}
  52. </view>
  53. <view class="protext">
  54. {{product.brandName ? product.brandName : ''}} {{product.brief ? product.brief : ''}}
  55. </view>
  56. <!-- <view class="xiaodian dflex" wx:if="{{hideShop=='true'}}">
  57. <image :src="picUrlss+'xdbg1.png'" class="xdbg"></image>
  58. <view class="shouyi flex">
  59. <text>销售收益</text>
  60. <view>8.65<text>元</text></view>
  61. </view>
  62. <view class="addshop" bindtap="addShop">添加到小店</view>
  63. </view> -->
  64. </view>
  65. <view class="detinfo mt20 bgfff">
  66. <!-- <view class="item dflex">
  67. <label>优惠券</label>
  68. <view class="quan flex dflex">
  69. <view class="flex dflex">
  70. <text>满500减50</text>
  71. <text>满200减10</text>
  72. </view>
  73. <view class="ling dflex">领券<image src="/pages/images/more3.png"></image></view>
  74. </view>
  75. </view> -->
  76. <view class="item dflex">
  77. <label>配送至</label>
  78. <view class="flex" @tap="toAddress">
  79. <view class="address">{{address.address}}{{address.house}}</view>
  80. <view class="huo"><text>现货</text>
  81. <!-- 现在下单,预计2小时后送达 -->
  82. </view>
  83. </view>
  84. <image src="/static/pages/images/more2.png" class="more" @tap="toAddress"></image>
  85. </view>
  86. <!-- <view class="item dflex">
  87. <label>服务门店</label>
  88. <view class="flex" bindtap="updateShop">
  89. <view class="address">{{merchant.title}}</view>
  90. </view>
  91. </view> -->
  92. </view>
  93. <!-- 海外购 -->
  94. <!-- <view class="detinfo mt20 bgfff" wx:if="{{product.isOtc==5}}">
  95. <view class="item">
  96. <view class="dflex">
  97. <label>物流</label>
  98. <view class="">
  99. <view class="address">20:00前付款,预计9月30日前送达</view>
  100. </view>
  101. </view>
  102. <view class="dflex logistics">
  103. <view class="lsicText">
  104. <image src="/product/image/abroad.png" class="abroad"></image>
  105. 德国进口
  106. </view>
  107. <image src="/product/image/you_h.png" class="you"></image>
  108. <view class="lsicText">
  109. <image src="/product/image/bonded.png" class="abroad"></image>
  110. 保税店
  111. </view>
  112. <image src="/product/image/you.png" class="you"></image>
  113. <view>
  114. <image src="/product/image/position.png" class="abroad"></image>
  115. 长沙市
  116. </view>
  117. </view>
  118. </view>
  119. </view> -->
  120. <!-- 商品详情等页面 -->
  121. <product-footer id="list" ref="list" :detail="nodes" :imgs="imgs" :proId="product.id" v-if="product.id"
  122. :form="form" @scoreTab="scoreTab" @showTab="showTab" @freshen="freshenFun"></product-footer>
  123. <v-share :hide-toast="hideShare" :product="product" :code-url="codeUrl" @onFather="click"></v-share>
  124. <view class="placeholder-view" :style="'height:' + (bottomBlankHeight + 140) + 'rpx'"></view>
  125. <view class="bot fixed bgfff dflex" :style="'padding-bottom: ' + (bottomBlankHeight + 20) + 'rpx'">
  126. <view class="btnfot">
  127. <button open-type="contact" class="botbtn">
  128. <image src="/static/pages/images/kfico.png"></image>客服
  129. </button>
  130. <navigator class="botbtn" open-type="reLaunch" url="/integralshop/cart/cart?integralshop=1"
  131. hover-class="none">
  132. <image src="/static/pages/images/gwc.png"></image>购物车<text class="message"
  133. v-if="product.count > 0">{{product.count}}</text>
  134. </navigator>
  135. </view>
  136. <view class="btnbuy">
  137. <view :class="'addcart ' + (product.stock >= 1 && product.state == 1 ? '' : 'gray')"
  138. @tap="product.stock >= 1 && product.state == 1 ? addShopCart() : ''">加入购物车</view>
  139. <view class="gmbtn mbglinear" @tap="atOnceBuy" v-if="product.stock >= 1 && product.state == 1">
  140. {{product.isOtc==1 ?'预约下单': '立即兑换'}}
  141. </view>
  142. <view class="gmbtn mbggray" v-if="product.stock < 1 && product.state == 1">立即兑换</view>
  143. <!-- <view class="gmbtn kan-guoqi" wx:if="{{product.stock < 1 && product.state == 1}}">
  144. 商品已售罄</view> -->
  145. <!-- <view class="integral mbggray" >积分不足</view> -->
  146. <view class="gmbtn mbggray" v-if="product.state == 2">已下架</view>
  147. </view>
  148. </view>
  149. <view class="xiajia" v-if="product.stock < 1 && product.state == 1">您来晚了,商品已经卖完了</view>
  150. <view class="xiajia" v-if="product.state == 2">您来晚了,商品已经下架</view>
  151. <!-- 商品规格 -->
  152. <block v-if="isShow">
  153. <product-popup :product="product" :order-type="'11'" :is-cart="isCart" :is-timely="product.isTimely"
  154. :merchant="merchant" :merchant-id="merchantId" @hidePopup="hidePopup" @addCartSuccess="addCartSuccess">
  155. </product-popup>
  156. </block>
  157. <!-- 返回顶部 -->
  158. <view class="contact_index" @tap="goTop">
  159. <image src="/static/pages/images/backtop.png"></image>顶部
  160. </view>
  161. <!-- 添加到小店成功 -->
  162. <!-- <view class="mask" hidden="{{isHide}}" bindtap="hidePop"></view>
  163. <view class="suc" hidden="{{isHide}}">
  164. <image :src="picUrlss + 'tjcg1.png'" class="tjcg1"></image>
  165. <image :src="picUrlss+'tjcg.png'" class="tjcg"></image>
  166. <text>快去我的小店看看吧</text>
  167. <navigator url="/mine/shop/shop" hover-class="none" class="shop">我的小店</navigator>
  168. <view class="share-btn dflex">
  169. <button class="wxfriend dflex" open-type="share">
  170. <image src="/pages/images/wechat.png"></image>
  171. 微信好友
  172. </button>
  173. <view class="wxposter dflex" bindtap="generatePoster">
  174. <image src="/pages/images/poster.png"></image>
  175. 生成海报
  176. </view>
  177. </view>
  178. <image src="/pages/images/close2.png" class="suc-close" bindtap="hidePop"></image>
  179. </view> -->
  180. <update-userinfo :update-info="isUpdateInfo" :update-mobile="isUpdateMobile" v-if="isShowUpdate"
  181. @closeUpdate="closeUpdate"></update-userinfo>
  182. <privacy></privacy>
  183. <!-- #ifdef H5 -->
  184. <wx-share ref="wxshare" />
  185. <!-- #endif -->
  186. </view>
  187. </template>
  188. <script>
  189. const app = getApp();
  190. const req = require("../../utils/request.js");
  191. const utils = require("../../utils/util.js");
  192. var QQMapWX = require("../../utils/qqmap.js");
  193. const route = require("../../utils/route");
  194. import productPopup from "../../components/product-popup/index";
  195. import vShare from "../../components/share/share";
  196. export default {
  197. data() {
  198. return {
  199. picUrlss: req.public.picUrls,
  200. bottomBlankHeight: app.globalData.isIPhoneX ? 68 : 0,
  201. swiperCurrent: 0,
  202. bannerUrls: [],
  203. isShow: false,
  204. pro: {},
  205. isCart: false,
  206. timer: [],
  207. hideShare: true,
  208. codeUrl: '',
  209. contentList: [{
  210. pic: "/static/pages/images/bar.png",
  211. name: '好风依旧',
  212. time: '4秒前'
  213. }, {
  214. pic: "/static/pages/images/bar.png",
  215. name: '杨鑫',
  216. time: '20秒前'
  217. }, {
  218. pic: "/static/pages/images/bar.png",
  219. name: '杨鑫',
  220. time: '5秒前'
  221. }],
  222. isNotice: false,
  223. form: {
  224. page: 1,
  225. limit: 10
  226. },
  227. freshen: true // hideShop: '',//隐藏添加到小店
  228. // isHide: true,//添加小店成功弹窗
  229. ,
  230. current: "",
  231. merchantId: "",
  232. hideShop: "",
  233. merchant: "",
  234. shopId: "",
  235. imgs: [],
  236. product: "",
  237. nodes: "",
  238. address: "",
  239. popup: "",
  240. tabIndex: "",
  241. allShow: false,
  242. isVideoScene: false, //立即购买是否需要登录
  243. isShowUpdate: false, //是否显示更新信息弹窗
  244. isUpdateInfo: false, //更新用户信息
  245. isUpdateMobile: false, //绑定手机号
  246. };
  247. },
  248. components: {
  249. productPopup,
  250. vShare
  251. },
  252. props: {},
  253. onLoad: async function(options) {
  254. if (options.appId) req.setStorage('appId', options.appId);
  255. let that = this;
  256. // console.log(options);
  257. this.query = options;
  258. if (options.scene) {
  259. this.scene = options.scene;
  260. this.merchantId = options.merchantId;
  261. }
  262. if (options.merchantId) {
  263. that.setData({
  264. merchantId: options.merchantId
  265. });
  266. }
  267. if (options.isShare || options.isShareTimeline) {
  268. req.setStorage('pidCode', options.userId);
  269. let params = {
  270. userId: options.userId,
  271. merchantId: options.merchantId ? options.merchantId : '',
  272. }
  273. await this.bindUser(params);
  274. } else {
  275. await req.silenceLogin();
  276. }
  277. if (options.hideShop) {
  278. this.setData({
  279. hideShop: this.query.hideShop
  280. });
  281. } else {
  282. this.setData({
  283. hideShop: 'true'
  284. });
  285. }
  286. if (options.merchantId && options.merchantId != 'undefined') {
  287. req.getRequest('/api/merchant/detail', {
  288. id: options.merchantId
  289. }, data => {
  290. var timestamp = Date.parse(new Date());
  291. data.time = timestamp + 1 * 60 * 1000
  292. req.setStorage("MERCHANT", data);
  293. that.setData({
  294. merchant: data
  295. });
  296. // console.log(data, "执行+++++++++++++++++++++");
  297. });
  298. } else {
  299. let merchant = req.getStorage('MERCHANT');
  300. this.setData({
  301. merchant: merchant
  302. });
  303. } // else{
  304. // req.getRequest('/api/merchant/getMerchantList',{}, res => {
  305. // res = res.filter(it=>it.isDefault==1)
  306. // req.setStorage('MERCHANT', res[0]);
  307. // this.data.merchant=res[0]
  308. // that.setData({merchant:res[0]})
  309. // console.log(this.data.merchant)
  310. // })
  311. // }
  312. setInterval(() => {
  313. this.setData({
  314. isNotice: true
  315. });
  316. }, 10000);
  317. },
  318. onShow: async function() {
  319. if (req.getStorage('isVideoScene') && (req.getStorage('scene') == 1176 || req.getStorage('scene') ==
  320. 1177 || req.getStorage('scene') == 1195)) {
  321. this.isVideoScene = true
  322. }
  323. if (this.freshen) {
  324. await this.loadCodeParams();
  325. this.loadProudct(this.query);
  326. this.loadDefaultAddress();
  327. this.browsRecound(this.query.id);
  328. }
  329. },
  330. onShareAppMessage: function() {
  331. return this.onShareMessage();
  332. // let merchantId=''
  333. // // if(this.data.merchant.isDefault!=1){
  334. // // merchantId=this.data.merchant.id
  335. // // }
  336. // if(this.query.merchantId) merchantId=this.query.merchantId
  337. // return {
  338. // title: this.data.product.title,
  339. // imageUrl: this.data.product.pic,
  340. // path: '/integralshop/detail/detail?id=' + this.query.id + '&isShare=' + true + '&userId=' + req.getStorage('userInfo').id+'&merchantId='+merchantId
  341. // }
  342. },
  343. onReachBottom() {
  344. if (this.is_open_comments == 1 && this.tabIndex == 2) {
  345. this.form.page++;
  346. this.setData({
  347. ['form.page']: this.form.page
  348. });
  349. // this.selectComponent("#list").loadScore(this.current);
  350. this.$refs.list.loadScore(this.current);
  351. }
  352. } // addShop() {//添加到小店
  353. // req.postRequest('/api/shopProduct/save',{productId:this.data.product.id,type:1},data=>{
  354. // console.log(data)
  355. // this.setData({ isHide: false })
  356. // })
  357. // },
  358. // hidePop() {//添加到小店
  359. // this.setData({ isHide: true })
  360. // }
  361. ,
  362. onReady() {
  363. // #ifdef H5
  364. var that = this;
  365. //初始化分享内容
  366. setTimeout(function() {
  367. var shareContent = that.onShareMessage();
  368. if (shareContent) {
  369. shareContent.path = window.location.origin + shareContent.path;
  370. }
  371. console.log('分享内容》》》》》', shareContent);
  372. that.$refs.wxshare.init(shareContent);
  373. }, 4 * 1000);
  374. // #endif
  375. },
  376. methods: {
  377. onShareMessage() {
  378. let merchantId = '';
  379. let path = '';
  380. let isSolution = '';
  381. // #ifndef H5
  382. isSolution = req.env[req.env.NODE_ENV].isSolution;
  383. // #endif
  384. // #ifdef H5
  385. isSolution = false;
  386. // #endif
  387. let userInfo = req.getStorage('userInfo');
  388. let shopId = '';
  389. if (isSolution) {
  390. path = '/share/home/index?appId=' + req.getStorage('appId') + '&userId=' + userInfo.id;
  391. } else {
  392. path = '/integralshop/detail/detail?id=' + this.query.id + '&isShare=' + true + '&appId=' + req
  393. .getStorage('appId');
  394. // console.log(!req.getStorage('userInfo').id);
  395. if (!userInfo.id) {} else {
  396. path += '&userId=' + userInfo.id;
  397. }
  398. // console.log(this.query.merchantId);
  399. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  400. path += '&merchantId=' + req.getStorage('MERCHANT').id;
  401. merchantId = req.getStorage('MERCHANT').id;
  402. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  403. path += '&shopId=' + req.getStorage('smallShop').id;
  404. shopId = req.getStorage('smallShop').id;
  405. merchantId = req.getStorage('smallShop').merchantDTO.id;
  406. }
  407. }
  408. }
  409. route.share(1, userInfo.id, path, merchantId, shopId, 1, this.query.id);
  410. // console.log(path);
  411. return {
  412. title: this.product.title,
  413. imageUrl: this.product.pic,
  414. path: path
  415. };
  416. },
  417. bindUser(par) {
  418. let userInfo = req.getStorage('userInfo');
  419. if (!userInfo) {
  420. req.silenceLogin(par.userId, par.merchantId ? par.merchantId : par.shopId ? par.shopId : '');
  421. }
  422. },
  423. click(e) {
  424. // console.log(e)
  425. this.hideShare = e
  426. },
  427. showShare() {
  428. // #ifndef H5
  429. req.isLogin().then(success => {
  430. if (success) {
  431. this.setData({
  432. hideShare: false
  433. });
  434. this.getCodeUrl()
  435. }
  436. });
  437. // #endif
  438. },
  439. /**
  440. * 轮播切换
  441. */
  442. swiperChange({
  443. detail
  444. }) {
  445. if (this.current == 0 && this.swiperCurrent > 1) {
  446. //卡死时,重置current为正确索引
  447. this.setData({
  448. current: this.swiperCurrent
  449. });
  450. } else {
  451. //正常轮转时,记录正确页码索引
  452. this.setData({
  453. swiperCurrent: detail.current
  454. });
  455. }
  456. },
  457. dotEvent(e) {
  458. this.setData({
  459. current: e.currentTarget.dataset.current
  460. });
  461. },
  462. browsRecound(id) {
  463. let from = {
  464. bindId: id,
  465. type: 1,
  466. page: '/integralshop/detail/detail?id=' + this.query.id
  467. }; // if(this.query.scene){
  468. // from.shareType=12
  469. // from.page='/product/detail/detail?id=' + this.data.query.id +'&scene='+this.query.scene
  470. // if(!this.data.params.merchantId){}else{
  471. // from.merchantId=this.data.params.merchantId
  472. // }
  473. // if(!this.data.params.shopId){}else{
  474. // from.shopId=this.data.params.shopId
  475. // }
  476. // if(!this.data.params.userId){}else{
  477. // from.uid=this.data.params.userId
  478. // }
  479. // }
  480. if (this.query.isShare) {
  481. from.shareType = 1;
  482. from.page = '/integralshop/detail/detail?id=' + this.query.id + '&isShare=' + true;
  483. if (!this.query.userId) {} else {
  484. from.page += '&userId=' + this.query.userId;
  485. }
  486. if (!this.query.merchantId) {} else {
  487. from.merchantId = this.query.merchantId;
  488. }
  489. if (!this.query.shopId) {} else {
  490. from.shopId = this.query.shopId;
  491. }
  492. if (!this.query.userId) {} else {
  493. from.uid = this.query.userId;
  494. }
  495. }
  496. if (this.query.isShareTimeline) {
  497. from.shareType = 2;
  498. from.page = '/integralshop/detail/detail?id=' + this.query.id + '&isShareTimeline=' + true;
  499. if (!this.query.userId) {} else {
  500. from.page += '&userId=' + this.query.userId;
  501. }
  502. if (!this.query.merchantId) {} else {
  503. from.merchantId = this.query.merchantId;
  504. }
  505. if (!this.query.shopId) {} else {
  506. from.shopId = this.query.shopId;
  507. }
  508. if (!this.query.userId) {} else {
  509. from.uid = this.query.userId;
  510. }
  511. }
  512. req.postRequest('/api/browse', from, data => {});
  513. },
  514. // 选择服务门店
  515. updateShop() {
  516. let url = 'merchant/nearby/nearby?isChoose=true';
  517. app.globalData.openPage(url); // let url = 'merchant/nearby/nearby';
  518. // app.openPage(url)
  519. },
  520. loadCodeParams() {
  521. let _ts = this;
  522. return new Promise((resolve, reject) => {
  523. let form = {
  524. scene: _ts.scene
  525. };
  526. if (!_ts.scene) {
  527. resolve();
  528. return false;
  529. }
  530. if (_ts.merchantId) {
  531. // console.log("解析出来有门店");
  532. form.merchantId = _ts.merchantId;
  533. }
  534. req.getRequest('/api/code/params', form, data => {
  535. let res = data.scene.split('_');
  536. res.map(it => {
  537. if (it.indexOf('poid') > -1) {
  538. _ts.query.id = it.split('=')[1]
  539. }
  540. if (it.indexOf('mid') > -1) {
  541. _ts.query.merchantId = it.split('=')[1]
  542. }
  543. if (it.indexOf('sid') > -1) {
  544. _ts.query.shopId = it.split('=')[1]
  545. }
  546. })
  547. req.setStorage('pidCode', data.userId); // if (this.query.scene) {
  548. req.setStorage('appId', res[res.length - 1]);
  549. resolve();
  550. });
  551. });
  552. },
  553. loadProudct(query) {
  554. // console.log(this.query)
  555. // const query = this.query;
  556. let that = this;
  557. // console.log(query.merchantId);
  558. let form = {
  559. id: query.id
  560. };
  561. if (query.merchantId) form.merchantId = query.merchantId;
  562. let isShowLoading = false;
  563. if (!isShowLoading) {
  564. req.loadIng('加载中');
  565. isShowLoading = true;
  566. }
  567. req.getRequest('/api/product/detail', form, data => {
  568. //富文本图片放大
  569. var nodes = data.detail;
  570. if (data.isOtc == 5) {
  571. uni.setNavigationBarTitle({
  572. title: '海外购'
  573. });
  574. }
  575. that.setData({
  576. bannerUrls: data.images,
  577. product: data,
  578. nodes: nodes,
  579. allShow: true
  580. });
  581. if (isShowLoading) {
  582. uni.hideLoading();
  583. isShowLoading = false;
  584. }
  585. // if (data.detail) {
  586. // this.setData({ detail: data.detail.replace(/\<img/gi, '<img class="rich-img"') })
  587. // }
  588. });
  589. },
  590. getCodeUrl() {
  591. let that = this;
  592. let scene = 'poid=' + that.product.id;
  593. if (!this.merchantId) {} else {
  594. scene += '_mid=' + this.merchantId;
  595. }
  596. if (req.getStorage('appId')) scene += '_' + req.getStorage('appId');
  597. // console.log(scene); //获取小程序码
  598. const params = {
  599. page: 'integralshop/detail/detail',
  600. scene: scene
  601. }; // if(this.data.merchant&&this.data.merchant.isDefault!=1){
  602. // params.merchantId=this.data.merchant.id
  603. // }
  604. if (this.query.merchantId) var merchantId = this.query.merchantId;
  605. req.getRequest('/api/program/codev', params, url => {
  606. that.setData({
  607. codeUrl: url
  608. });
  609. });
  610. },
  611. loadDefaultAddress() {
  612. if (req.isAuth()) {
  613. req.g('/api/address/default', data => {
  614. if (data) this.setData({
  615. address: data
  616. });
  617. else this.pointLocation();
  618. }, true);
  619. } else {
  620. this.pointLocation();
  621. }
  622. },
  623. pointLocation() {
  624. //定位当前位置
  625. let _ts = this;
  626. QQMapWX.initMap(req.public.mapLBSKEY);
  627. req.getLocation(res => {
  628. QQMapWX.reverseGeocoder(res, data => {
  629. _ts.setData({
  630. 'address.address': data.address
  631. });
  632. });
  633. });
  634. },
  635. toAddress() {
  636. app.globalData.openPage('mine/address/address');
  637. },
  638. atOnceBuy() {
  639. if (this.isVideoScene && !req.getStorage('userInfo')) {
  640. this.bindUser()
  641. return false;
  642. }
  643. if (!this.getUpdate()) return false;
  644. if (!this.query.merchantId) this.setData({
  645. index: 'index'
  646. });
  647. this.setData({
  648. isShow: true,
  649. isCart: false,
  650. popup: this.product
  651. });
  652. },
  653. addShopCart() {
  654. if (this.isVideoScene && !req.getStorage('userInfo')) {
  655. this.bindUser()
  656. return false;
  657. }
  658. if (!this.getUpdate()) return false;
  659. if (!this.query.merchantId) this.setData({
  660. index: 'index'
  661. });
  662. this.setData({
  663. isShow: true,
  664. isCart: true,
  665. popup: this.product
  666. });
  667. },
  668. hidePopup() {
  669. this.setData({
  670. isShow: false
  671. });
  672. },
  673. addCartSuccess(event) {
  674. this.setData({
  675. 'product.count': parseInt(this.product.count) + parseInt(event.detail.quantity),
  676. isShow: false
  677. });
  678. },
  679. clickCollect() {
  680. let _ts = this;
  681. req.postRequest('/api/collect', {
  682. bindId: this.product.id,
  683. type: 1
  684. }, data => {
  685. _ts.setData({
  686. 'product.isCollect': !_ts.product.isCollect
  687. });
  688. });
  689. },
  690. goTop: function(e) {
  691. // 一键回到顶部
  692. if (uni.pageScrollTo) {
  693. uni.pageScrollTo({
  694. scrollTop: 0
  695. });
  696. } else {
  697. uni.showModal({
  698. title: '提示',
  699. content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
  700. });
  701. }
  702. },
  703. onShareTimeline() {
  704. let merchantId = '';
  705. let path = 'id=' + this.query.id + '&isShareTimeline=' + true + '&appId=' + req.getStorage('appId');
  706. if (!req.getStorage('userInfo').id) {} else {
  707. path += '&userId=' + req.getStorage('userInfo').id;
  708. }
  709. // console.log(this.merchantId);
  710. let shopId = '';
  711. if (!this.merchantId) {
  712. // console.log(123, path);
  713. } else {
  714. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  715. path += '&merchantId=' + req.getStorage('MERCHANT').id;
  716. merchantId = req.getStorage('MERCHANT').id;
  717. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  718. path += '&shopId=' + req.getStorage('smallShop').id;
  719. shopId = req.getStorage('smallShop').id;
  720. merchantId = req.getStorage('smallShop').merchantDTO.id;
  721. }
  722. }
  723. }
  724. let url = '/integralshop/detail/detail?' + path;
  725. route.share(2, req.getStorage('userInfo').id, url, merchantId, shopId, 1, this.query.id);
  726. // console.log(path, url);
  727. return {
  728. title: this.product.title,
  729. query: path,
  730. imageUrl: this.product.images[0]
  731. }; // return {
  732. // title: this.data.product.title,
  733. // path: this.data.product.images[0]
  734. // }
  735. },
  736. showTab: function(e) {
  737. this.setData({
  738. tabIndex: e.detail
  739. });
  740. },
  741. scoreTab: function(e) {
  742. this.form.page = 0;
  743. this.setData({
  744. current: e.detail,
  745. ['form.page']: 1
  746. });
  747. },
  748. freshenFun: function(e) {
  749. this.setData({
  750. freshen: e.detail
  751. });
  752. },
  753. getUpdate() {
  754. let userInfos = req.getStorage('userInfo');
  755. if (!userInfos.mobile) {
  756. console.log('没有手机号')
  757. this.isShowUpdate = true;
  758. this.isUpdateMobile = true;
  759. req.setStorage('isShowUpdateMobile', true)
  760. return false;
  761. }
  762. if (!userInfos.avatar || userInfos.avatar.indexOf('thirdwx.qlogo') > -1 || userInfos.nickName.indexOf(
  763. '用户') > -1) {
  764. console.log('没有昵称')
  765. this.isShowUpdate = true;
  766. this.isUpdateInfo = true;
  767. req.setStorage('isShowUpdateInfo', true)
  768. return false;
  769. }
  770. return true;
  771. },
  772. closeUpdate() {
  773. this.isShowUpdate = false
  774. this.isUpdateInfo = false;
  775. this.isUpdateMobile = false;
  776. },
  777. }
  778. };
  779. </script>
  780. <style>
  781. @import "./detail.css";
  782. </style>