detail.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206
  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.imageList" :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.imageList" :key="index">
  15. <view :class="'dot ' + (index == swiperCurrent ? ' active' : '')" :data-current="index"
  16. @tap="dotEvent"></view>
  17. </block>
  18. </view>
  19. </view>
  20. <view class="info bgfff">
  21. <view class="infos dflex">
  22. <view class="price dflex">
  23. ¥<text>{{product.minSalePrice}}<block v-if="product.maxSalePrice>product.minSalePrice">-{{product.maxSalePrice}}</block></text>
  24. <text class="origin"
  25. v-if="product.salePrice == product.actualPrice && product.marketPrice > 0&&product.salePrice<product.marketPrice">¥{{product.marketPrice}}</text>
  26. </view>
  27. <view class=" sellStock" v-if="product.sellStock>0">销量:<text>{{product.sellStock}}</text></view>
  28. <view class="share" @tap="showShare">
  29. <image src="/static/pages/images/fxico.png"></image>分享
  30. </view>
  31. </view>
  32. <view class="huiyuan" @tap="govip"
  33. v-if="show_membership_price==1&&product.membersPrice!=null"><!-- &&product.membersPrice<product.salePrice -->
  34. <view class="dflex huiyuanjia">
  35. <view class="dflex">
  36. <!-- <image src="/product/static/product/image/huiyuanjia.png" class="huiyuanimg"></image> -->
  37. {{userInfo.level && userInfo.level != 'LV0' ? userInfo.level : '会员价'}}
  38. <text class="hymoney">¥{{product.actualPrice < product.salePrice ? product.actualPrice : product.membersPrice}}</text>
  39. 立省¥{{product.jianMoney?product.jianMoney:'0'}}
  40. </view>
  41. <view class="d-open" v-if="!userInfo.level">立即开通</view>
  42. <image src="/product/static/product/image/govip.png" class="govipimg" v-else></image>
  43. </view>
  44. </view>
  45. <view class="title">
  46. <image src="/static/pages/images/jishida.png" class="tag" v-if="product.isJs&&merchant.type!=5&& about.timely_close != 1">
  47. </image>
  48. <image src="/product/static/product/image/overseasPurchase.png" class="tag" v-if="product.isOtc===5">
  49. </image>
  50. <text class="yushou" v-if="product.estimatedDeliveryTimeStr">预售</text>{{product.title?product.title:''}}
  51. </view>
  52. <view class="protext">
  53. {{product.brandName ? product.brandName : ''}} {{product.brief ? product.brief : ''}}
  54. </view>
  55. <view class="guarantee dflex" v-if="guarantee.length>0">
  56. <view class="cont dflex">
  57. <view v-for="(item, index) in guarantee" :key="index" class="dflex li">
  58. <image src="/product/static/product/image/guarantee.png"></image>{{item}}
  59. </view>
  60. </view>
  61. </view>
  62. <!-- isOtc 0 默认 1 处方药 2 非处方药 3 医疗器械 4 食品类 5 海外购 -->
  63. <block v-if="product.isOtc!=5">
  64. <block v-if="is_open_shop == 1 && ascription">
  65. <view class="xiaodian dflex malr20"
  66. v-if="((product.isMeCommission != 1 || product.isMeCommission != '1') && product.oneCommission>0) || ((product.isMeCommission == 1 || product.isMeCommission == '1') && product.twoCommission>0) || product.serviceShopRate">
  67. <image :src="picUrlss + 'xdbg1.png'" class="xdbg"></image>
  68. <view class="shouyi flex"
  69. v-if="((product.isMeCommission != 1 || product.isMeCommission != '1') && product.oneCommission>0) || ((product.isMeCommission == 1 || product.isMeCommission == '1') && product.twoCommission>0)">
  70. <text>预计分销收益</text>
  71. <view v-if="product.isMeCommission == 0"><text>¥</text>{{product.oneCommission}}</view>
  72. <view v-else><text>¥</text>{{product.twoCommission}}</view>
  73. </view>
  74. <view class="shouyi flex" v-if="product.serviceShopRate">
  75. <text>预计小店服务费</text>
  76. <view><text>¥</text>{{product.serviceShopRate}}</view>
  77. </view>
  78. <view class="dflex" v-if="product.isJoinShop">
  79. <view class="fenxiang" @tap="showShare">分享推广</view>
  80. <navigator :url="url" hover-class="none" class="goShop">去小店</navigator>
  81. </view>
  82. <view class="addshop" @tap="addShop" v-else>添加到小店</view>
  83. </view>
  84. </block>
  85. <block v-else>
  86. <view class="xiaodian dflex malr20"
  87. v-if="((product.isMeCommission != 1 || product.isMeCommission != '1') && product.oneCommission>0) || ((product.isMeCommission == 1 || product.isMeCommission == '1') && product.twoCommission>0)">
  88. <image :src="picUrlss + 'xdbg1.png'" class="xdbg"></image>
  89. <view class="shouyi flex">
  90. <text>预计分销收益</text>
  91. <view v-if="product.isMeCommission == 0"><text>¥</text>{{product.oneCommission}}</view>
  92. <view v-else><text>¥</text>{{product.twoCommission}}</view>
  93. </view>
  94. <navigator url="/promote/apply/apply" hover-class="none" class="fenxiang"
  95. v-if="isDistriUser != 2">我要推广</navigator>
  96. <view class="fenxiang" @tap="showShare" v-else>分享推广</view>
  97. </view>
  98. </block>
  99. </block>
  100. </view>
  101. <view class="merge">
  102. <view class="m-tit">套餐内容</view>
  103. <view class="m-list">
  104. <view class="li ddflex" v-for="(item,index) in product.nodeList" :key="index" v-if="index < nodeIndex" @click="jumpUrl('/product/detail/detail?id=' + item.product.id)">
  105. <image :src="item.product.pic" mode="aspectFill"></image>
  106. <view class="fflex">
  107. <view class="m-pro-tit">{{item.product.title}}</view>
  108. <view class="m-pro-specs" v-if="item.productSku.properties&&item.productSku.properties!='DEFAULT_SKU'">规格<text v-for="(it,idx) in JSON.parse(item.productSku.properties)" :key="idx">{{it.value}}</text></view>
  109. <view class="m-pro-opt ddflex">
  110. <view class="m-pro-price">¥<text>{{item.productSku.salePrice}}</text></view>
  111. <view class="m-pro-count">×{{item.quantity}}</view>
  112. </view>
  113. </view>
  114. </view>
  115. </view>
  116. <view :class="'colle ddflex' + (isCollapse?' active':'')" v-if="product.nodeList.length > 3" @click="collapse">{{isCollapse?'收起':'查看'}}更多<image src="../../static/pages/images/bico.png"></image></view>
  117. </view>
  118. <view class="detinfo mt20 bgfff">
  119. <view class="item pro-sel dflex" v-if="product.propertiesList && product.propertiesList.length > 0"
  120. @click="product.stock > 0 ? addShopCart() : ''">
  121. <label>已选</label>
  122. <view class="flex">{{product.properties}}</view>
  123. <image src="/static/pages/images/more.png" class="mrico"></image>
  124. </view>
  125. <view class="item pro-time dflex" v-if="product.estimatedDeliveryTimeStr">
  126. <label>预计发货时间</label>
  127. <view class="flex">{{product.estimatedDeliveryTimeStr}} 前发货</view>
  128. </view>
  129. <view class="item dflex">
  130. <label>配送至</label>
  131. <view class="flex" @tap="toAddress">
  132. <view class="address">{{address.address?address.address:''}}{{address.house?address.house:''}}</view>
  133. </view>
  134. <image src="/static/pages/images/more2.png" class="more" @tap="toAddress"></image>
  135. </view>
  136. <view class="item dflex"><!-- v-if="merchant.isDefault!=1" -->
  137. <label>当前门店</label>
  138. <view class="flex" @tap="updateShop">
  139. <view class="address">{{merchant.title}}</view>
  140. </view>
  141. <image src="/static/pages/images/more2.png" class="more" @tap="updateShop"></image>
  142. </view>
  143. <navigator :url="'/product/supplier/supplier?id=' + product.supplierModel.id" hover-class="none" class="item det-sup dflex" v-if="about.is_show_supplier == 1 && product.supplierModel">
  144. <label>供应商</label>
  145. <view class="flex">
  146. <view class="dflex">
  147. <view class="sup-name flex tover">{{product.supplierModel.name}}</view>
  148. <image src="/static/pages/images/more.png" class="mrico"></image>
  149. </view>
  150. <view class="sup-bri tover" v-if="product.supplierModel.businessScope">主营范围:{{product.supplierModel.businessScope}}</view>
  151. </view>
  152. </navigator>
  153. </view>
  154. <!-- 商品详情等页面 -->
  155. <product-footer ref="list" id="list" :detail="nodes" :imgs="imgs" :proId="product.id" :form="form" :is-merge="1"
  156. @scoreTab="scoreTab" @showTab="showTab" v-if="product.id" @freshen="freshenFun" @getForm="getForm">
  157. </product-footer>
  158. <v-share :hide-toast="hideShare" :product="product" :code-url="codeUrl" @onFather="click"></v-share>
  159. <view class="placeholder-view" :style="'height:' + (bottomBlankHeight + 140) + 'rpx'"></view>
  160. <view class="bot fixed bgfff dflex" :style="'padding-bottom: ' + (bottomBlankHeight + 20) + 'rpx'">
  161. <view class="btnfot">
  162. <navigator class="botbtn" open-type="reLaunch" url="/pages/index/index" hover-class="none">
  163. <image src="/static/pages/images/sy.png"></image>首页
  164. </navigator>
  165. </view>
  166. <view class="btnbuy">
  167. <view class="gmbtn mbglinear fflex" @tap="atOnceBuy" v-if="product.quantity >= 1 && product.state == 1">
  168. 马上抢
  169. </view>
  170. <view class="gmbtn mbggray fflex" v-if="(product.quantity < 1)&&load">已售罄</view>
  171. <block v-else>
  172. <view class="gmbtn mbggray fflex" v-if="(product.state != 1)&&load">已下架</view>
  173. </block>
  174. <view class="gmbtn mbggray fflex" v-if="product.quantity < 1 && product.state == 1">马上抢
  175. </view>
  176. </view>
  177. </view>
  178. <view class="xiajia" v-if="product.quantity < 1">您来晚了,商品已售罄</view>
  179. <block v-else>
  180. <view class="xiajia" v-if="(product.state !=1) &&load">您来晚了,商品已经下架</view>
  181. </block>
  182. <!-- 商品规格 -->
  183. <block v-if="isShow">
  184. <product-popup :product="popup" :order-type="991" :is-cart="isCart" :is-timely="product.isTimely"
  185. :merchant="merchant" :merchant-id="merchantId" @hidePopup="hidePopup" @addCartSuccess="addCartSuccess"
  186. :index="index" :shopId="query.shopId" @freshen="changeFreshen" @getPor="getPor">
  187. </product-popup>
  188. </block>
  189. <!-- 返回顶部 -->
  190. <contact-button img-url="/static/pages/images/kfico1.png" class-name="side-contact" button-text="客服"></contact-button>
  191. <view class="contact_index" @tap="goTop">
  192. <image src="/static/pages/images/backtop.png"></image>顶部
  193. </view>
  194. <!-- 添加到小店成功 -->
  195. <view class="mask" :hidden="isHide" @tap="hidePop"></view>
  196. <view class="suc" :hidden="isHide">
  197. <image :src="picUrlss + 'tjcg1.png'" class="tjcg1"></image>
  198. <image :src="picUrlss+'tjcg.png'" class="tjcg"></image>
  199. <text>快去我的小店看看吧</text>
  200. <view class="shopcc dflex">
  201. <view class="shop" @tap="showShare">分享推广</view>
  202. <navigator :url="url" hover-class="none" class="shop">我的小店</navigator>
  203. </view>
  204. <image src="/static/pages/images/close2.png" class="suc-close" @tap="hidePop"></image>
  205. </view>
  206. <block v-if="isActive">
  207. <product-acitvity @hideActive="hideActive"></product-acitvity>
  208. </block>
  209. <block v-if="isPopupLogin">
  210. <product-login :about="about" @hidePopupLogin="hidePopupLogin"></product-login>
  211. </block>
  212. <!-- 订单购买轮播 -->
  213. <view :class="(marqueeOrderItem ? 'roll-notice ' : '') + 'dflex'" v-if="marqueeOrderItem">
  214. <image :src="marqueeOrderItem.avatar"></image>
  215. <view class="flex">{{ marqueeOrderItem.time }} 购买了{{ marqueeOrderItem.productName }}</view>
  216. </view>
  217. <update-userinfo :update-info="isUpdateInfo" :update-mobile="isUpdateMobile" v-if="isShowUpdate" @closeUpdate="closeUpdate"></update-userinfo>
  218. <privacy></privacy>
  219. <!-- #ifdef H5 -->
  220. <wx-share ref="wxshare" />
  221. <!-- #endif -->
  222. </view>
  223. </template>
  224. <script>
  225. const app = getApp();
  226. const req = require("../../utils/request.js");
  227. const utils = require("../../utils/util.js");
  228. var QQMapWX = require("../../utils/qqmap.js");
  229. const route = require("../../utils/route");
  230. const api = require("../../utils/api.js");
  231. import productPopup from "../../components/product-popup/index";
  232. import vShare from "../../components/share/share";
  233. import productAcitvity from "../../components/product-activity/index";
  234. import productLogin from "../../components/product-login/index";
  235. export default {
  236. data() {
  237. return {
  238. picUrlss: req.public.picUrls,
  239. bottomBlankHeight: app.globalData.isIPhoneX ? 68 : 0,
  240. swiperCurrent: 0,
  241. bannerUrls: [],
  242. isShow: false,
  243. pro: {},
  244. isCart: false,
  245. timer: [],
  246. hideShare: true,
  247. codeUrl: '',
  248. form: {
  249. page: 1,
  250. limit: 10
  251. },
  252. contentList: [{
  253. pic: "/static/pages/images/bar.png",
  254. name: '好风依旧',
  255. time: '4秒前'
  256. }, {
  257. pic: "/static/pages/images/bar.png",
  258. name: '杨鑫',
  259. time: '20秒前'
  260. }, {
  261. pic: "/static/pages/images/bar.png",
  262. name: '杨鑫',
  263. time: '5秒前'
  264. }],
  265. isNotice: false,
  266. hideShop: true,
  267. //隐藏添加到小店
  268. isHide: true,
  269. //添加小店成功弹窗
  270. url: '/mine/shop/shop',
  271. freshen: true,
  272. //是否更新页面
  273. isActive: false,
  274. current: "",
  275. query: "",
  276. merchantId: "",
  277. merchant: "",
  278. userInfo: "",
  279. ascription: false, //是否开启小店
  280. guarantee: "",
  281. show_membership_price: "",
  282. Is_Store_Price_Stock: "",
  283. is_open_shop: "",
  284. is_open_comments: "",
  285. shopId: "",
  286. params: "",
  287. product: "",
  288. nodes: "",
  289. imgs: [],
  290. tabe: "",
  291. load: false,
  292. address: {},
  293. index: "",
  294. popup: "",
  295. tabIndex: "",
  296. switch: true,
  297. about: {},
  298. allShow: false,
  299. isDistriUser: 0, // 判断用户是否是分销员 2为分销员
  300. isPopupLogin: false,
  301. marqueeOrderItemIndex: 0,
  302. marqueeOrderItem: '',
  303. isShowTime: false,
  304. couponList: [],
  305. isVideoScene: false,//立即购买是否需要登录
  306. isShowUpdate: false,//是否显示更新信息弹窗
  307. isUpdateInfo: false,//更新用户信息
  308. isUpdateMobile: false,//绑定手机号
  309. nodeIndex: 3,
  310. isCollapse: false,
  311. isShowUpdate: false,//是否显示更新信息弹窗
  312. isUpdateInfo: false,//更新用户信息
  313. isUpdateMobile: false,//绑定手机号
  314. };
  315. },
  316. components: {
  317. productPopup,
  318. vShare,
  319. productAcitvity,
  320. productLogin
  321. },
  322. props: {},
  323. onLoad: async function(options) {
  324. if(options.appId) req.setStorage('appId',options.appId);
  325. let that = this;
  326. // console.log(options);
  327. this.query = options;
  328. this.setData({
  329. query: options
  330. });
  331. if (options.scene) {
  332. this.scene = options.scene;
  333. this.merchantId = options.merchantId;
  334. }
  335. if (options.merchantId) {
  336. that.setData({
  337. merchantId: options.merchantId
  338. });
  339. }
  340. if (options.isShare || options.isShareTimeline) {
  341. req.setStorage('pidCode', options.userId);
  342. let params = {
  343. userId: options.userId,
  344. merchantId: options.merchantId ? options.merchantId : '',
  345. }
  346. await this.bindUser(params);
  347. }else{
  348. await req.silenceLogin();
  349. }
  350. if (options.hideShop) {
  351. this.setData({
  352. hideShop: false
  353. });
  354. } // if (options.merchantId && options.merchantId != 'undefined') {
  355. // req.getRequest('/api/merchant/detail', { id: options.merchantId }, data => {
  356. // req.setStorage("MERCHANT", data)
  357. // that.setData({ merchant: data })
  358. // console.log(data, "执行+++++++++++++++++++++")
  359. // })
  360. // } else {
  361. // let merchant = req.getStorage('MERCHANT');
  362. // this.setData({ merchant: merchant });
  363. // }
  364. // else{
  365. // // req.getRequest('/api/merchant/getMerchantList',{}, res => {
  366. // // res = res.filter(it=>it.isDefault==1)
  367. // // req.setStorage('MERCHANT', res[0]);
  368. // // this.data.merchant=res[0]
  369. // // that.setData({merchant:res[0]})
  370. // // console.log(this.data.merchant)
  371. // // })
  372. // let merchant=req.getStorage('MERCHANT')
  373. // that.setData({merchant:merchant})
  374. // }
  375. this.isShop()
  376. setInterval(() => {
  377. this.setData({
  378. isNotice: true
  379. });
  380. }, 10000);
  381. },
  382. onShow: async function() {
  383. if(req.getStorage('isVideoScene') && (req.getStorage('scene') == 1176 || req.getStorage('scene') == 1177 || req.getStorage('scene') == 1195)){
  384. this.isVideoScene = true
  385. }
  386. if (this.freshen) {
  387. let that = this;
  388. await this.loadCodeParams();
  389. if (that.scene) {
  390. await that.bindUser(that.params);
  391. }
  392. this.getGuarantee().then(data => {
  393. // console.log("debug1", data);
  394. if (this.switch) {
  395. this.getMerchant()
  396. }
  397. })
  398. await this.getProductCoupon()
  399. // if (this.switch) {
  400. // this.getMerchant()
  401. // }
  402. await this.browsRecound(this.query.id);
  403. }
  404. this.getBuyOrderMarquee(!this.isShowTime);
  405. },
  406. onShareAppMessage() {
  407. // console.log(options);
  408. return this.onShareMessage();
  409. },
  410. onReachBottom() {
  411. if (this.is_open_comments == 1 && this.tabIndex == 2) {
  412. this.form.page++;
  413. this.setData({
  414. ['form.page']: this.form.page
  415. });
  416. // this.selectComponent("#list").loadScore(this.current);
  417. // console.log(this.form, "++++++++++++++++")
  418. this.$refs.list.loadScore(this.current, this.form);
  419. }
  420. },
  421. onReady() {
  422. // #ifdef H5
  423. var that = this;
  424. //初始化分享内容
  425. setTimeout(function() {
  426. var shareContent = that.onShareMessage();
  427. if (shareContent) {
  428. shareContent.path = window.location.origin + shareContent.path;
  429. }
  430. console.log('分享内容》》》》》', shareContent);
  431. that.$refs.wxshare.init(shareContent);
  432. }, 4 * 1000);
  433. // #endif
  434. },
  435. methods: {
  436. onShareMessage(){
  437. let merchantId = '';
  438. let path = '';
  439. let isSolution = '';
  440. // #ifndef H5
  441. isSolution = req.env[req.env.NODE_ENV].isSolution;
  442. // #endif
  443. // #ifdef H5
  444. isSolution = false;
  445. // #endif
  446. let userInfo = req.getStorage('userInfo');
  447. let shopId = '';
  448. if(isSolution){
  449. path = '/share/home/index?appId='+req.getStorage('appId')+'&userId='+userInfo.id;
  450. }else{
  451. path = '/product/mergeDetail/detail?id=' + this.query.id + '&isShare=' + true + '&appId=' + req.getStorage('appId');
  452. if (!userInfo.id) {} else {
  453. path += '&userId=' + userInfo.id;
  454. }
  455. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  456. path += '&merchantId=' + req.getStorage('MERCHANT').id;
  457. merchantId = req.getStorage('MERCHANT').id;
  458. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  459. path += '&shopId=' + req.getStorage('smallShop').id;
  460. shopId = req.getStorage('smallShop').id;
  461. merchantId = req.getStorage('smallShop').merchantDTO.id;
  462. }
  463. }
  464. }
  465. route.share(1, userInfo.id, path, merchantId, shopId, 1, this.query.id);
  466. return {
  467. title: this.product.title,
  468. imageUrl: this.product.pic,
  469. path: path
  470. };
  471. },
  472. collapse(){
  473. if(this.isCollapse){
  474. this.nodeIndex = 3;
  475. }else{
  476. this.nodeIndex = this.product.nodeList.length;
  477. }
  478. this.isCollapse = !this.isCollapse
  479. },
  480. getBuyOrderMarquee(isToTime) {
  481. console.log('getBuyOrderMarquee数据获取>>>>>>');
  482. req.getRequest('/api/product/buyDynamic', {}, data => {
  483. this.isShowTime = true;
  484. this.buyOrderMarqueeList = data;
  485. if (isToTime) {
  486. if (this.buyOrderMarqueeList && this.buyOrderMarqueeList.length > 0) {
  487. this.marqueeOrderItem = this.buyOrderMarqueeList[this.marqueeOrderItemIndex];
  488. this.marqueeOrderItemIndex++;
  489. this.getMarqueeOrderItem();
  490. }
  491. }
  492. });
  493. },
  494. // 首页轮播最新购买记录
  495. getMarqueeOrderItem() {
  496. var tha = this;
  497. setTimeout(function() {
  498. // console.log('数据tha.marqueeOrderItemIndex>>>>', tha.marqueeOrderItemIndex);
  499. tha.marqueeOrderItem = tha.buyOrderMarqueeList[tha.marqueeOrderItemIndex];
  500. if (tha.marqueeOrderItemIndex >= tha.buyOrderMarqueeList.length - 1) {
  501. tha.marqueeOrderItemIndex = 0;
  502. } else {
  503. tha.marqueeOrderItemIndex++;
  504. }
  505. tha.getMarqueeOrderItem();
  506. }, 5000);
  507. },
  508. bindUser(par) {
  509. let userInfo = req.getStorage('userInfo');
  510. if (!userInfo) {
  511. // uni.login({
  512. // success(res) {
  513. // let params = {
  514. // code: res.code,
  515. // }
  516. // if(par.userId){
  517. // params.parentId = par.userId;
  518. // }
  519. // if(par.merchantId || par.shopId){
  520. // params.merchantId = par.merchantId ? par.merchantId : par.shopId ? par.shopId : ''
  521. // }
  522. // return new Promise((resolve, reject) => {
  523. // req.postRequest('/api/v2/login', params, data => {
  524. // resolve();
  525. // });
  526. // })
  527. // }
  528. // });
  529. // this.isPopupLogin = true;
  530. req.silenceLogin(par.userId, par.merchantId ? par.merchantId : par.shopId ? par.shopId : '');
  531. }
  532. },
  533. click(e) {
  534. // console.log(e,"7899")
  535. this.hideShare = e
  536. },
  537. getMerchant() {
  538. let that = this;
  539. api.getMerchant(this.query, req, data => {
  540. that.loadDefaultAddress();
  541. if (data == 1) {
  542. if(that.about.Many_Store == 1) api.locationShow()
  543. else{
  544. that.getuserInfo(data);
  545. if(req.getStorage('defaultMerchant')) {
  546. that.merchant = req.getStorage('defaultMerchant');
  547. that.query.merchantId = that.merchant.id
  548. }else{
  549. api.defaultMerchant(req, _ts.query, defaultRes=>{
  550. that.merchant = defaultRes;
  551. that.query.merchantId = defaultRes.id
  552. });
  553. }
  554. that.loadProudct(that.query);
  555. }
  556. } else {
  557. that.getuserInfo(data);
  558. if (req.getStorage('userInfo') && that.merchant.id != data.id) {
  559. if (data.type == 5) {
  560. that.query.merchantId = data.merchantDTO.id
  561. that.query.shopId = data.id
  562. } else {
  563. that.query.merchantId = data.id
  564. }
  565. this.loadProudct(this.query);
  566. let pages = getCurrentPages();
  567. var prevPage = pages[pages.length - 2];
  568. // console.log(prevPage, '++++++++++++++++++')
  569. if (prevPage) {
  570. prevPage.$vm.setData({
  571. freshen: true
  572. });
  573. }
  574. } else {
  575. this.loadProudct(this.query);
  576. }
  577. that.merchant = data
  578. }
  579. })
  580. },
  581. showShare() {
  582. // console.log(11111,this.hideShare)
  583. // #ifdef H5
  584. this.setData({
  585. hideShare: false
  586. });
  587. // #endif
  588. // #ifndef H5
  589. req.isLogin().then(success => {
  590. // console.log(success)
  591. if (success) {
  592. this.getCodeUrl()
  593. this.setData({
  594. hideShare: false
  595. });
  596. // console.log(this.hideShare)
  597. }
  598. });
  599. // #endif
  600. },
  601. /**
  602. * 轮播切换
  603. */
  604. swiperChange({
  605. detail
  606. }) {
  607. if (this.current == 0 && this.swiperCurrent > 1) {
  608. //卡死时,重置current为正确索引
  609. this.setData({
  610. current: this.swiperCurrent
  611. });
  612. } else {
  613. //正常轮转时,记录正确页码索引
  614. this.setData({
  615. swiperCurrent: detail.current
  616. });
  617. }
  618. },
  619. dotEvent(e) {
  620. this.setData({
  621. current: e.currentTarget.dataset.current
  622. });
  623. },
  624. // 获取用户信息
  625. getuserInfo(data) {
  626. let that = this;
  627. let userInfo = req.getStorage('userInfo');
  628. // console.log(data, userInfo);
  629. if (userInfo && userInfo.listShopBase && userInfo.listShopBase != null && userInfo.listShopBase.length >
  630. 0) {
  631. if (userInfo.listShopBase[0].merchant_id == data.id && data.type != 5) {
  632. let url = '/mine/shop/shop?merchantId=' + userInfo.listShopBase[0].merchant_id + '&shopId=' +
  633. userInfo.listShopBase[0].id;
  634. that.ascription = true;
  635. that.url = url
  636. }
  637. console.log('that.userInfo==' + that.userInfo)
  638. }
  639. },
  640. // 获取品质保证
  641. getGuarantee() {
  642. return new Promise((data, rej) => {
  643. req.getRequest('/api/config', {}, res => {
  644. req.setStorage('configRes', JSON.stringify(res))
  645. this.about = res
  646. data(res)
  647. if (!this.query.merchantId || this.merchant && this.merchant.isDefault == 1) {
  648. // 切割;拿到数组,然后在过滤掉空值
  649. if (res.b2c_service_guarantee && res.b2c_service_guarantee != null) {
  650. this.setData({
  651. guarantee: res.b2c_service_guarantee.split(";").filter(it => {
  652. return it = it && it.trim();
  653. })
  654. });
  655. }
  656. } else {
  657. if (res.o2o_service_guarantee && res.b2c_service_guarantee != null) {
  658. this.setData({
  659. guarantee: res.o2o_service_guarantee.split(";").filter(it => {
  660. return it = it && it.trim();
  661. })
  662. });
  663. }
  664. }
  665. if (res.show_membership_price) {
  666. this.setData({
  667. show_membership_price: res.show_membership_price
  668. });
  669. }
  670. if (res.Is_Store_Price_Stock) {
  671. this.setData({
  672. Is_Store_Price_Stock: res.Is_Store_Price_Stock
  673. });
  674. }
  675. if (res.is_open_shop) {
  676. this.setData({
  677. is_open_shop: res.is_open_shop
  678. });
  679. }
  680. if (res.is_open_comments) {
  681. this.setData({
  682. is_open_comments: res.is_open_comments
  683. });
  684. }
  685. });
  686. })
  687. },
  688. browsRecound(id) {
  689. let from = {
  690. bindId: id,
  691. type: 1,
  692. page: '/product/mergeDetail/detail?id=' + id
  693. };
  694. if (this.query.isShare) {
  695. from.shareType = 1;
  696. from.page = '/product/mergeDetail/detail?id=' + this.query.id + '&isShare=' + true;
  697. if (!this.query.userId) {} else {
  698. from.page += '&userId=' + this.query.userId;
  699. }
  700. if (!this.query.merchantId) {} else {
  701. from.merchantId = this.query.merchantId;
  702. }
  703. if (!this.query.shopId) {} else {
  704. from.shopId = this.query.shopId;
  705. }
  706. if (!this.query.userId) {} else {
  707. from.uid = this.query.userId;
  708. }
  709. }
  710. if (this.query.isShareTimeline) {
  711. from.shareType = 2;
  712. from.page = '/product/mergeDetail/detail?id=' + this.query.id + '&isShareTimeline=' + true;
  713. if (!this.query.userId) {} else {
  714. from.page += '&userId=' + this.query.userId;
  715. }
  716. if (!this.query.merchantId) {} else {
  717. from.merchantId = this.query.merchantId;
  718. }
  719. if (!this.query.shopId) {} else {
  720. from.shopId = this.query.shopId;
  721. }
  722. if (!this.query.userId) {} else {
  723. from.uid = this.query.userId;
  724. }
  725. }
  726. return new Promise((resolve,reject)=>{
  727. req.postRequest('/api/browse', from, data => {resolve()});
  728. })
  729. },
  730. govip() {
  731. uni.navigateTo({
  732. url: '/mine/vip/vip'
  733. });
  734. },
  735. loadProudct(query) {
  736. let that = this;
  737. that.getMy();
  738. that.setData({
  739. bannerUrls: [],
  740. product: '',
  741. nodes: ''
  742. });
  743. // console.log(query.merchantId);
  744. let form = {
  745. id: query.id
  746. };
  747. let isShowLoading = false;
  748. this.allShow = false
  749. if (!isShowLoading) {
  750. req.loadIng('加载中');
  751. isShowLoading = true;
  752. }
  753. req.getRequest('/api/v3/merge/detail', form, data => {
  754. //富文本图片放大
  755. var nodes = data.text;
  756. data.priceList.map(it=>{
  757. it.active = false;
  758. return it;
  759. })
  760. that.setData({
  761. bannerUrls: data.imageList,
  762. product: data,
  763. nodes: nodes,
  764. load: true,
  765. allShow: true
  766. });
  767. if (isShowLoading) {
  768. uni.hideLoading();
  769. isShowLoading = false;
  770. }
  771. if (data.membersPrice && data.actualPrice < data.salePrice) {
  772. let jian = parseFloat(data.salePrice - data.actualPrice).toFixed(2);
  773. this.setData({
  774. ['product.jianMoney']: jian
  775. });
  776. }
  777. if (data.membersPrice && data.membersPrice < data.salePrice) {
  778. let jian = parseFloat(data.salePrice - data.membersPrice).toFixed(2);
  779. this.setData({
  780. ['product.jianMoney']: jian
  781. });
  782. } // if (data.detail) {
  783. // this.setData({ detail: data.detail.replace(/\<img/gi, '<img class="rich-img"') })
  784. // }
  785. // that.getCodeUrl();
  786. });
  787. },
  788. getMy() {
  789. let that = this;
  790. let userInfo = req.getStorage('userInfo');
  791. if (!userInfo || userInfo == null) return false;
  792. req.getRequest('/api/user/my', {}, data => {
  793. that.userInfo = data;
  794. that.isDistriUser = data.isDistriUser;
  795. });
  796. },
  797. loadCodeParams() {
  798. let _ts = this;
  799. return new Promise((resolve, reject) => {
  800. let form = {
  801. scene: _ts.scene
  802. };
  803. if (!_ts.scene) {
  804. resolve();
  805. return false;
  806. } // if (_ts.merchantId) {
  807. // console.log("解析出来有门店")
  808. // form.merchantId = _ts.merchantId
  809. // }
  810. req.getRequest('/api/code/params', form, data => {
  811. // console.log("====================================================================================" + data.merchantId)
  812. // this.data.query.id = data.scene;
  813. let res = data.scene.split('_');
  814. let params = {
  815. userId: data.userId
  816. }
  817. res.map(it=>{
  818. if(it.indexOf('poid')>-1){
  819. _ts.query.id = it.split('=')[1]
  820. params.id = it.split('=')[1]
  821. }
  822. if(it.indexOf('mid')>-1){
  823. _ts.query.merchantId = it.split('=')[1]
  824. params.merchantId = it.split('=')[1]
  825. }
  826. if(it.indexOf('sid')>-1){
  827. _ts.query.shopId = it.split('=')[1]
  828. params.shopId = it.split('=')[1]
  829. }
  830. })
  831. req.setStorage('pidCode', data.userId);
  832. req.setStorage('appId',res[res.length-1]);
  833. this.setData({
  834. params: params
  835. });
  836. resolve();
  837. });
  838. });
  839. },
  840. getCodeUrl() {
  841. let that = this;
  842. let scene = 'poid='+that.product.id;
  843. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  844. scene += '_mid=' + req.getStorage('MERCHANT').id;
  845. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  846. scene += '_sid=' + req.getStorage('smallShop').id;
  847. }
  848. }
  849. if(req.getStorage('appId')) scene += '_'+ req.getStorage('appId');
  850. // console.log(scene); //获取小程序码
  851. const params = {
  852. page: 'product/mergeDetail/detail',
  853. scene: scene
  854. };
  855. req.getRequest('/api/program/codev', params, url => {
  856. that.setData({
  857. codeUrl: url
  858. });
  859. });
  860. },
  861. loadDefaultAddress() {
  862. if (req.isAuth()) {
  863. req.g('/api/address/default', data => {
  864. if (data) this.setData({
  865. address: data
  866. });
  867. else if(this.about.Many_Store == 1) this.pointLocation();
  868. }, true);
  869. } else {
  870. if(this.about.Many_Store == 1) this.pointLocation();
  871. }
  872. },
  873. pointLocation() {
  874. //定位当前位置
  875. let _ts = this;
  876. QQMapWX.initMap(req.public.mapLBSKEY);
  877. req.getLocation(res => {
  878. QQMapWX.reverseGeocoder(res, data => {
  879. _ts.setData({
  880. ['address.address']: data.address
  881. });
  882. });
  883. });
  884. },
  885. toAddress() {
  886. app.globalData.openPage('mine/address/address');
  887. },
  888. atOnceBuy() {
  889. // console.log(this.merchantId);
  890. if(this.isVideoScene && !req.getStorage('userInfo')){
  891. this.bindUser()
  892. return false;
  893. }
  894. if(!this.getUpdate()) return false;
  895. if (!this.query.merchantId) this.setData({
  896. index: 'index'
  897. });
  898. this.setData({
  899. isShow: true,
  900. isCart: false,
  901. popup: this.product
  902. });
  903. },
  904. onActive() {
  905. this.setData({
  906. isActive: true
  907. });
  908. },
  909. addShopCart() {
  910. if(this.isVideoScene && !req.getStorage('userInfo')){
  911. this.bindUser()
  912. return false;
  913. }
  914. if(!this.getUpdate()) return false;
  915. if (!this.query.merchantId) this.setData({
  916. index: 'index'
  917. });
  918. this.setData({
  919. isShow: true,
  920. isCart: true,
  921. popup: this.product
  922. });
  923. },
  924. hidePopup() {
  925. this.setData({
  926. isShow: false
  927. });
  928. },
  929. changeFreshen(){
  930. this.freshen = false;
  931. },
  932. hidePopupLogin(data) {
  933. this.isPopupLogin = false;
  934. },
  935. hideActive() {
  936. this.setData({
  937. isActive: false
  938. });
  939. },
  940. addCartSuccess(event) {
  941. this.setData({
  942. 'product.count': parseInt(this.product.count) + parseInt(event.detail.quantity),
  943. isShow: false
  944. });
  945. },
  946. clickCollect() {
  947. let _ts = this;
  948. req.postRequest('/api/collect', {
  949. bindId: this.product.id,
  950. type: 1
  951. }, data => {
  952. _ts.setData({
  953. 'product.isCollect': !_ts.product.isCollect
  954. });
  955. });
  956. },
  957. goTop: function(e) {
  958. // 一键回到顶部
  959. if (uni.pageScrollTo) {
  960. uni.pageScrollTo({
  961. scrollTop: 0
  962. });
  963. } else {
  964. uni.showModal({
  965. title: '提示',
  966. content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
  967. });
  968. }
  969. },
  970. onShareTimeline() {
  971. let merchantId = '';
  972. let path = 'id=' + this.query.id + '&isShareTimeline=' + true+'&appId='+req.getStorage('appId');
  973. if (!req.getStorage('userInfo').id) {} else {
  974. path += '&userId=' + req.getStorage('userInfo').id;
  975. }
  976. // console.log(this.query.merchantId);
  977. let shopId = '';
  978. if (!this.query.merchantId) {
  979. // console.log(123, path);
  980. } else {
  981. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  982. path += '&merchantId=' + req.getStorage('MERCHANT').id;
  983. merchantId = req.getStorage('MERCHANT').id;
  984. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  985. path += '&shopId=' + req.getStorage('smallShop').id;
  986. shopId = req.getStorage('smallShop').id;
  987. merchantId = req.getStorage('smallShop').merchantDTO.id;
  988. }
  989. }
  990. }
  991. let url = '/product/mergeDetail/detail?' + path;
  992. route.share(2, req.getStorage('userInfo').id, url, merchantId, shopId, 1, this.query.id);
  993. // console.log(path, url);
  994. return {
  995. title: this.product.title,
  996. query: path,
  997. imageUrl: this.product.images[0]
  998. };
  999. },
  1000. // 选择服务门店
  1001. updateShop(type) {
  1002. let url = 'merchant/nearby/nearby?isChoose=true';
  1003. if (type == 1) {
  1004. url += '&type=' + type;
  1005. }
  1006. if (this.about.User_Limit_Store == 1) {
  1007. } else {
  1008. app.globalData.openPage(url);
  1009. }
  1010. },
  1011. onHide() {
  1012. this.setData({
  1013. load: false
  1014. })
  1015. },
  1016. // 是否开启小店
  1017. isShop() {
  1018. if (req.getStorage('distribution')) {
  1019. let dist = req.getStorage('distribution')
  1020. this.setData({
  1021. distr: dist
  1022. })
  1023. console.log(dist)
  1024. if (dist.distributionSmallShopOpen == 1) {
  1025. req.postRequest('/api/shopBase/isOpenShop', {}, data => {
  1026. this.setData({
  1027. isshop: data
  1028. })
  1029. console.log(data)
  1030. })
  1031. }
  1032. }
  1033. },
  1034. addShop() {
  1035. //添加到小店
  1036. req.postRequest('/api/shopProduct/save', {
  1037. productId: this.product.id,
  1038. type: 1
  1039. }, data => {
  1040. // console.log(data);
  1041. this.setData({
  1042. isHide: false
  1043. });
  1044. this.product.isJoinShop = true;
  1045. });
  1046. },
  1047. hidePop() {
  1048. //添加到小店
  1049. this.setData({
  1050. isHide: true
  1051. });
  1052. },
  1053. showTab: function(e) {
  1054. this.setData({
  1055. tabIndex: e.detail
  1056. });
  1057. },
  1058. scoreTab: function(e) {
  1059. this.form.page = 0;
  1060. this.setData({
  1061. current: e.detail,
  1062. ['form.page']: 1
  1063. });
  1064. },
  1065. freshenFun: function(e) {
  1066. this.setData({
  1067. freshen: e.detail
  1068. });
  1069. },
  1070. getForm: function(e) {
  1071. // console.log(e.detail,"qqqqq")
  1072. this.form.page = e.detail
  1073. },
  1074. getPor: function(e) {
  1075. // console.log(e.detail, "qqqqq")
  1076. this.popup = e.detail
  1077. this.product = e.detail
  1078. },
  1079. getProductCoupon(){
  1080. let form = {
  1081. page: 1,
  1082. limit: 3,
  1083. productId: this.query.id
  1084. }
  1085. return new Promise((resolve,reject)=>{
  1086. req.getRequest('/api/coupon/listV2',form,data=>{
  1087. this.couponList = data;
  1088. resolve();
  1089. })
  1090. })
  1091. },
  1092. jumpUrl(url){
  1093. uni.navigateTo({
  1094. url: url
  1095. })
  1096. },
  1097. getUpdate() {
  1098. let userInfos = req.getStorage('userInfo');
  1099. if(!userInfos.mobile){
  1100. console.log('没有手机号')
  1101. this.isShowUpdate = true;
  1102. this.isUpdateMobile = true;
  1103. req.setStorage('isShowUpdateMobile',true)
  1104. return false;
  1105. }
  1106. if (!userInfos.avatar || userInfos.avatar.indexOf('thirdwx.qlogo') > -1 || userInfos.nickName.indexOf('用户') > -1 ) {
  1107. console.log('没有昵称')
  1108. this.isShowUpdate = true;
  1109. this.isUpdateInfo = true;
  1110. req.setStorage('isShowUpdateInfo',true)
  1111. return false;
  1112. }
  1113. return true;
  1114. },
  1115. closeUpdate(){
  1116. this.isShowUpdate = false
  1117. this.isUpdateInfo = false;
  1118. this.isUpdateMobile = false;
  1119. },
  1120. }
  1121. };
  1122. </script>
  1123. <style>
  1124. @import "./detail.css";
  1125. </style>