detail.vue 40 KB

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