newbornDetails.vue 32 KB

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