newbornDetails.vue 35 KB

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