newbornDetails.vue 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135
  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="picUrlss+'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. picUrlss: req.public.picUrls,
  246. bottomBlankHeight: app.globalData.isIPhoneX ? 68 : 0,
  247. swiperCurrent: 0,
  248. bannerUrls: [],
  249. isShow: false,
  250. pro: {},
  251. timer: [],
  252. orderType: '',
  253. isRemind: false,
  254. hideShare: true,
  255. isCart: false,
  256. codeUrl: '',
  257. contentList: [{
  258. pic: "/static/pages/images/bar.png",
  259. name: '好风依旧',
  260. time: '4秒前'
  261. }, {
  262. pic: "/static/pages/images/bar.png",
  263. name: '杨鑫',
  264. time: '20秒前'
  265. }, {
  266. pic: "/static/pages/images/bar.png",
  267. name: '杨鑫',
  268. time: '5秒前'
  269. }],
  270. isNotice: false,
  271. user: true,
  272. form: {
  273. page: 1,
  274. limit: 10
  275. },
  276. freshen: true //是否更新页面
  277. ,
  278. current: "",
  279. query: "",
  280. imgs: "",
  281. activityEnd: false,
  282. act: "",
  283. address: {},
  284. popup: {},
  285. params: "",
  286. tabIndex: "",
  287. guarantee: "",
  288. is_open_comments: "",
  289. merchant: "",
  290. merchantId: "",
  291. shopId: "",
  292. nodes: "",
  293. switch: true,
  294. about: {},
  295. allShow: false,
  296. isHide: true,//添加小店成功弹窗
  297. is_open_shop: '',//商户是否开启分销
  298. ascription: false,//是否开启小店
  299. isDistriUser: 0, // 判断用户是否是分销员 2为分销员
  300. isPopupLogin: false
  301. };
  302. },
  303. components: {
  304. productFooter,
  305. productPopup,
  306. vShare,
  307. productLogin
  308. },
  309. props: {},
  310. /**
  311. * 生命周期函数--监听页面加载
  312. */
  313. onLoad: function(options) {
  314. this.query = options;
  315. this.setData({
  316. query: options
  317. });
  318. if (options.scene) {
  319. this.scene = options.scene;
  320. }
  321. if (options.isShare) {
  322. this.query.id = options.id;
  323. this.query.acid = options.acid;
  324. req.setStorage('pidCode', options.userId);
  325. let params = {
  326. userId: options.userId,
  327. merchantId: options.merchantId ? options.merchantId : '',
  328. }
  329. this.bindUser(params);
  330. }
  331. // console.log(options);
  332. // console.info(options);
  333. setInterval(() => {
  334. this.setData({
  335. isNotice: true
  336. });
  337. }, 10000);
  338. },
  339. onUnload() {
  340. if (this.timer) clearInterval(this.timer);
  341. },
  342. onShareAppMessage: function() {
  343. let merchantId = '';
  344. let path = '/activity/newbornDetails/newbornDetails?id=' + this.query.id + '&acid=' + this.query.acid +
  345. '&isShare=' +
  346. true;
  347. // console.log(!req.getStorage('userInfo').id);
  348. if (!req.getStorage('userInfo').id) {} else {
  349. path += '&userId=' + req.getStorage('userInfo').id;
  350. }
  351. // console.log(this.query.merchantId);
  352. let shopId = '';
  353. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  354. path += '&merchantId=' + req.getStorage('MERCHANT').id;
  355. merchantId = req.getStorage('MERCHANT').id;
  356. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  357. path += '&shopId=' + req.getStorage('smallShop').id;
  358. shopId = req.getStorage('smallShop').id;
  359. merchantId = req.getStorage('smallShop').merchantDTO.id;
  360. }
  361. }
  362. // console.log(path)
  363. route.share(1, req.getStorage('userInfo').id, path, merchantId, shopId, 8, this.query.acid + '_' + this
  364. .query.id);
  365. return {
  366. title: this.pro.title,
  367. imageUrl: this.pro.pic,
  368. path: path
  369. }; // return {
  370. // title: this.data.pro.title,
  371. // imageUrl: this.data.pro.pic,
  372. // path: '/activity/newbornDetails/newbornDetails?id=' + this.query.id + '&acid=' + this.query.acid + '&isShare=' + true + '&userId=' + req.getStorage('userInfo').id+'&merchantId='+this.data.query.merchantId
  373. // }
  374. },
  375. /**
  376. * 生命周期函数--监听页面初次渲染完成
  377. */
  378. onReady: function() {},
  379. /**
  380. * 生命周期函数--监听页面显示
  381. */
  382. onShow: async function() {
  383. let that = this
  384. if (this.freshen) {
  385. await this.loadCodeParams();
  386. if(that.scene){
  387. await that.bindUser(that.query);
  388. }
  389. this.getGuarantee().then(data => {
  390. if (this.switch) {
  391. api.getMerchant(this.query, req, data => {
  392. that.loadDefaultAddress();
  393. if (data == 1) {
  394. api.locationShow()
  395. } else {
  396. that.getuserInfos(data);
  397. if (data.type == 5) {
  398. that.query.merchantId = data.merchantDTO.id
  399. that.query.shopId = data.id
  400. } else {
  401. that.query.merchantId = data.id
  402. }
  403. if (req.getStorage('userInfo') && that.merchant.id != data.id) {
  404. this.loadProudct();
  405. let pages = getCurrentPages();
  406. var prevPage = pages[pages.length - 2];
  407. if (prevPage) {
  408. prevPage.$vm.setData({
  409. freshen: true
  410. });
  411. }
  412. } else {
  413. this.loadProudct();
  414. }
  415. that.merchant = data
  416. // console.log(that.query.merchantId,"dddddd")
  417. }
  418. })
  419. }
  420. })
  421. // this.loadDefaultAddress();
  422. this.newuser();
  423. await this.browsRecound(this.query.id)
  424. }
  425. },
  426. /**
  427. * 生命周期函数--监听页面隐藏
  428. */
  429. onHide: function() {},
  430. /**
  431. * 生命周期函数--监听页面卸载
  432. */
  433. onUnload: function() {},
  434. /**
  435. * 页面相关事件处理函数--监听用户下拉动作
  436. */
  437. onPullDownRefresh: function() {},
  438. /**
  439. * 页面上拉触底事件的处理函数
  440. */
  441. onReachBottom: function() {},
  442. onReachBottom() {
  443. if (this.is_open_comments == 1 && this.tabIndex == 2) {
  444. this.form.page++;
  445. this.setData({
  446. ['form.page']: this.form.page
  447. });
  448. // this.selectComponent("#list").loadScore(this.current);
  449. this.$refs.list.loadScore(this.current);
  450. }
  451. },
  452. methods: {
  453. bindUser(par){
  454. let userInfo = req.getStorage('userInfo');
  455. if(!userInfo){
  456. // uni.login({
  457. // success(res) {
  458. // let params = {
  459. // code: res.code,
  460. // parentId: par.userId,
  461. // merchantId: par.merchantId ? par.merchantId : par.shopId ? par.shopId : ''
  462. // }
  463. // return new Promise((resolve,reject)=>{
  464. // req.postRequest('/api/v2/login', params, data => {
  465. // resolve();
  466. // });
  467. // })
  468. // }
  469. // });
  470. // this.isPopupLogin = true;
  471. req.silenceLogin(par.userId, par.merchantId ? par.merchantId : par.shopId ? par.shopId : '');
  472. }
  473. },
  474. click(e) {
  475. // console.log(e)
  476. this.hideShare = e
  477. },
  478. showShare() {
  479. // #ifndef H5
  480. req.isLogin().then(success => {
  481. if (success) {
  482. this.getCodeUrl()
  483. this.setData({
  484. hideShare: false
  485. });
  486. }
  487. });
  488. // #endif
  489. },
  490. /**
  491. * 轮播切换
  492. */
  493. swiperChange({
  494. detail
  495. }) {
  496. if (this.current == 0 && this.swiperCurrent > 1) {
  497. //卡死时,重置current为正确索引
  498. this.setData({
  499. current: this.swiperCurrent
  500. });
  501. } else {
  502. //正常轮转时,记录正确页码索引
  503. this.setData({
  504. swiperCurrent: detail.current
  505. });
  506. }
  507. },
  508. dotEvent(e) {
  509. this.setData({
  510. current: e.currentTarget.dataset.current
  511. });
  512. },
  513. browsRecound(id) {
  514. let from = {
  515. bindId: id,
  516. type: 8,
  517. page: '/activity/newbornDetails/newbornDetails?id=' + this.query.id + '&acid=' + this.query.acid
  518. }; // if(this.query.scene){
  519. // from.shareType=12
  520. // from.page='/activity/seckillDetails/seckillDetails?id=' + this.query.id+'&acid=' + this.query.acid +'&scene='+this.query.scene
  521. // if(!this.data.params.merchantId){}else{
  522. // from.merchantId=this.data.params.merchantId
  523. // }
  524. // if(!this.data.params.shopId){}else{
  525. // from.shopId=this.data.params.shopId
  526. // }
  527. // if(!this.data.params.userId){}else{
  528. // from.uid=this.data.params.userId
  529. // }
  530. // }
  531. if (this.query.isShare) {
  532. from.shareType = 1;
  533. from.page = '/activity/newbornDetails/newbornDetails?id=' + this.query.id + '&acid=' + this.query
  534. .acid +
  535. '&isShare=' + true;
  536. if (!this.query.userId) {} else {
  537. from.page += '&userId=' + this.query.userId;
  538. }
  539. if (!this.query.merchantId) {} else {
  540. from.merchantId = this.query.merchantId;
  541. }
  542. if (!this.query.shopId) {} else {
  543. from.shopId = this.query.shopId;
  544. }
  545. if (!this.query.userId) {} else {
  546. from.uid = this.query.userId;
  547. }
  548. }
  549. if (this.query.isShareTimeline) {
  550. from.shareType = 2;
  551. from.page = '/activity/newbornDetails/newbornDetails?id=' + this.query.id + '&acid=' + this.query
  552. .acid +
  553. '&isShareTimeline=' + true;
  554. if (!this.query.userId) {} else {
  555. from.page += '&userId=' + this.query.userId;
  556. }
  557. if (!this.query.merchantId) {} else {
  558. from.merchantId = this.query.merchantId;
  559. }
  560. if (!this.query.shopId) {} else {
  561. from.shopId = this.query.shopId;
  562. }
  563. if (!this.query.userId) {} else {
  564. from.uid = this.query.userId;
  565. }
  566. }
  567. return new Promise((resolve,reject)=>{
  568. req.postRequest('/api/browse', from, data => {resolve()});
  569. })
  570. },
  571. getPor: function(e) {
  572. // console.log(e.detail, "qqqqq")
  573. this.popup = e.detail
  574. this.act.id = e.detail.actId
  575. },
  576. loadCodeParams() {
  577. let _ts = this;
  578. return new Promise((resolve, reject) => {
  579. if (!_ts.scene) {
  580. resolve();
  581. return false;
  582. }
  583. req.getRequest('/api/code/params', {
  584. scene: _ts.scene
  585. }, data => {
  586. if (data) {
  587. this.query.id = data.scene.split('_')[0];
  588. this.query.acid = data.scene.split('_')[1];
  589. this.query.merchantId = data.scene.split('_')[2];
  590. this.query.shopId = data.scene.split('_')[3];
  591. this.query.userId = data.userId;
  592. req.setStorage('pidCode', data.userId);
  593. }
  594. resolve();
  595. });
  596. });
  597. },
  598. getCodeUrl() {
  599. let that = this; //获取小程序码
  600. const query = this.query;
  601. let scene = that.pro.id + '_' + query.acid;
  602. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  603. scene += '_' + req.getStorage('MERCHANT').id;
  604. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  605. scene += '_' + req.getStorage('smallShop').id;
  606. }
  607. }
  608. // console.log(scene); //获取小程序码
  609. const params = {
  610. page: 'activity/newbornDetails/newbornDetails',
  611. scene: scene
  612. };
  613. // console.log('ma--', params);
  614. req.getRequest('/api/program/codev', params, url => {
  615. that.setData({
  616. codeUrl: url
  617. });
  618. });
  619. },
  620. async loadProudct() {
  621. let that = this;
  622. await that.loadActivity();
  623. const query = that.query;
  624. let isShowLoading = false;
  625. if (!isShowLoading) {
  626. req.loadIng('加载中');
  627. isShowLoading = true;
  628. }
  629. req.getRequest('/api/product/detail', {
  630. id: query.id
  631. }, data => {
  632. //富文本图片放大
  633. that.nodes = data.detail;
  634. let propertiesList = []
  635. if (data.propertiesList && data.propertiesList.length > 0) {
  636. data.propertiesList.map(it => {
  637. propertiesList.push(it.value);
  638. })
  639. }
  640. data.properties = propertiesList.join(' / ')
  641. that.setData({
  642. bannerUrls: data.images,
  643. pro: data,
  644. 'pro.salePrice': this.act.money,
  645. // 'pro.stock': this.act.quantity,
  646. 'pro.stock': this.act.quantity - this.act.payQuantity,
  647. 'pro.payQuantity': this.act.payQuantity,
  648. 'pro.maxBuy': this.act.maxBuy,
  649. allShow: true
  650. });
  651. if (isShowLoading) {
  652. uni.hideLoading();
  653. isShowLoading = false;
  654. }
  655. // console.log(this.pro);
  656. // that.getCodeUrl();
  657. });
  658. },
  659. loadActivity() {
  660. const query = this.query;
  661. return new Promise((resolve, reject) => {
  662. let from = {
  663. id: query.acid
  664. }
  665. if (!this.query.merchantId) {} else {
  666. from.merchantId = this.query.merchantId
  667. }
  668. let userInfo = req.getStorage('userInfo');
  669. if(userInfo.listShopBase && userInfo.listShopBase.length >0 ){
  670. from.shopId = userInfo.listShopBase[0].id;
  671. }
  672. req.getRequest('/api/activity/detail', from, data => {
  673. // console.log(data);
  674. this.getMy();
  675. if (data.type == 1) {
  676. this.setData({
  677. orderType: 2
  678. });
  679. }
  680. if (data.type == 2) {
  681. this.setData({
  682. orderType: 3
  683. });
  684. }
  685. if (data.type == 4) {
  686. this.setData({
  687. orderType: 6
  688. });
  689. }
  690. if (data.type == 5) {
  691. this.setData({
  692. orderType: 7
  693. });
  694. }
  695. if (!data || data == 2001) {
  696. this.setData({
  697. activityEnd: true
  698. });
  699. return false;
  700. } else {
  701. this.setData({
  702. act: data,
  703. isRemind: data.remindId
  704. });
  705. this.initTimer(data);
  706. }
  707. resolve();
  708. });
  709. });
  710. },
  711. // 获取用户信息
  712. getuserInfos(data) {
  713. let userInfo = req.getStorage('userInfo');
  714. if (userInfo && userInfo.listShopBase && userInfo.listShopBase != null && userInfo.listShopBase.length >
  715. 0) {
  716. if (userInfo.listShopBase[0].merchant_id == data.id && data.type != 5) {
  717. let url = '/mine/shop/shop?merchantId=' + userInfo.listShopBase[0].merchant_id + '&shopId=' + userInfo.listShopBase[0].id;
  718. this.url = url;
  719. this.ascription = true;
  720. }
  721. }
  722. },
  723. getMy() {
  724. let that = this;
  725. let userInfo = req.getStorage('userInfo');
  726. if(!userInfo || userInfo == null) return false;
  727. req.getRequest('/api/user/my', {}, data => {
  728. that.isDistriUser = data.isDistriUser;
  729. });
  730. },
  731. initTimer(group) {
  732. //计时器
  733. let _ts = this;
  734. let nowTime = new Date(group.nowTime.replace(/-/g, '/')).getTime();
  735. let startTime = new Date(group.startTime.replace(/-/g, '/')).getTime();
  736. let endTime = new Date(group.endTime.replace(/-/g, '/')).getTime();
  737. if (!group.start) endTime = startTime;
  738. let times = parseInt((endTime - nowTime) / 1000);
  739. // console.log(times / 60 / 60);
  740. this.timer = setInterval(() => {
  741. times--;
  742. if (times <= 0) {
  743. //重新加载列表
  744. _ts.setData({
  745. 'act.end': true
  746. });
  747. return false;
  748. }
  749. let n = utils.formatDayTimes(times);
  750. _ts.setData({
  751. timer: n.split(/:|天/g)
  752. });
  753. }, 1000);
  754. },
  755. loadDefaultAddress() {
  756. if (req.isAuth()) {
  757. req.g('/api/address/default', data => {
  758. if (data) this.setData({
  759. address: data
  760. });
  761. else this.pointLocation();
  762. }, true);
  763. } else {
  764. this.pointLocation();
  765. }
  766. },
  767. toAddress() {
  768. app.globalData.openPage('mine/address/address');
  769. },
  770. toMerchant() {
  771. if (this.about.User_Limit_Store == 1) {
  772. } else {
  773. app.globalData.openPage('pages/nearby/nearby?isChoose=true');
  774. }
  775. },
  776. toactive() {
  777. app.globalData.openPage('pages/nearby/nearby');
  778. },
  779. pointLocation() {
  780. //定位当前位置
  781. let _ts = this;
  782. QQMapWX.initMap();
  783. req.getLocation(res => {
  784. QQMapWX.reverseGeocoder(res, data => {
  785. _ts.setData({
  786. ['address.address']: data.address
  787. });
  788. });
  789. });
  790. },
  791. addCartSuccess(event) {
  792. this.setData({
  793. 'pro.count': parseInt(this.pro.count) + parseInt(event.detail.quantity),
  794. isShow: false
  795. });
  796. },
  797. atOnceBuy() {
  798. // //立即购买
  799. if (!this.user) return req.msg('您不是新用户');
  800. if (!this.act.start) return req.msg('活动还未开始');
  801. if (this.act.end) return req.msg('活动已结束');
  802. // this.setData({ isShow: true, isCart: false, popup: this.data.product });
  803. this.setData({
  804. isShow: true,
  805. isCart: false,
  806. popup: {
  807. id: this.pro.id,
  808. pic: this.pro.pic,
  809. title: this.pro.title,
  810. salePrice: this.act.money,
  811. stock: this.pro.stock,
  812. paramsId: this.pro.paramsId,
  813. marketPrice: this.pro.marketPrice,
  814. skuId: this.pro.skuId
  815. }
  816. });
  817. },
  818. /**
  819. * 判断是否为新用户,不是,2秒后为用户跳转至该商品的详情页面
  820. */
  821. newuser() {
  822. var id = this.query.id;
  823. if (req.getStorage('userInfo')) {
  824. req.postRequest('/api/order/isnew', {}, res => {
  825. if (res == 'false') {
  826. this.setData({
  827. user: false
  828. });
  829. // wx.showToast({
  830. // title: '您不是新用户,两秒后将为您跳转至该商品页面',
  831. // icon: 'none',
  832. // success: function () {
  833. // setTimeout(function () {
  834. // wx.redirectTo({ url: '/product/detail/detail?id=' + id })
  835. // }, 2000);
  836. // }
  837. // })
  838. }
  839. // console.log(res);
  840. });
  841. }
  842. },
  843. addShopCart() {
  844. if (!this.user) return req.msg('您不是新用户');
  845. if (this.act.end) return req.msg('活动已结束');
  846. this.setData({
  847. isShow: true,
  848. isCart: true,
  849. popup: {
  850. id: this.pro.id,
  851. pic: this.pro.pic,
  852. title: this.pro.title,
  853. salePrice: this.act.money,
  854. stock: this.pro.stock,
  855. paramsId: this.pro.paramsId,
  856. marketPrice: this.pro.marketPrice,
  857. skuId: this.pro.skuId
  858. }
  859. });
  860. },
  861. clickCollect() {
  862. let _ts = this;
  863. req.postRequest('/api/collect', {
  864. bindId: this.pro.id,
  865. type: 1
  866. }, data => {
  867. _ts.setData({
  868. 'pro.isCollect': !_ts.pro.isCollect
  869. });
  870. });
  871. },
  872. goTop: function(e) {
  873. // 一键回到顶部
  874. if (uni.pageScrollTo) {
  875. uni.pageScrollTo({
  876. scrollTop: 0
  877. });
  878. } else {
  879. uni.showModal({
  880. title: '提示',
  881. content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
  882. });
  883. }
  884. },
  885. onShareTimeline() {
  886. let merchantId = '';
  887. let path = 'id=' + this.query.id + '&acid=' + this.query.acid + '&isShareTimeline=' + true;
  888. if (!req.getStorage('userInfo').id) {} else {
  889. path += '&userId=' + req.getStorage('userInfo').id;
  890. }
  891. // console.log(this.merchantId);
  892. let shopId = '';
  893. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  894. path += '&merchantId=' + req.getStorage('MERCHANT').id;
  895. merchantId = req.getStorage('MERCHANT').id;
  896. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  897. path += '&shopId=' + req.getStorage('smallShop').id;
  898. shopId = req.getStorage('smallShop').id;
  899. merchantId = req.getStorage('smallShop').merchantDTO.id;
  900. }
  901. }
  902. let url = '/activity/newbornDetails/newbornDetails?' + path;
  903. route.share(2, req.getStorage('userInfo').id, url, merchantId, shopId, 8, this.query.acid + '_' + this
  904. .query.id);
  905. return {
  906. title: this.pro.title,
  907. query: path,
  908. imageUrl: this.pro.pic
  909. }; // return {
  910. // title: this.data.pro.title,
  911. // imageUrl: this.data.pro.pic
  912. // }
  913. },
  914. hidePopup() {
  915. this.setData({
  916. isShow: false
  917. });
  918. },
  919. hidePopupLogin(data) {
  920. this.isPopupLogin = false;
  921. },
  922. addActivityRemind() {
  923. // if (!this.data.user) return req.msg('您不是新用户')
  924. // 订阅调用
  925. req.postRequest('/api/activity/remind', {
  926. activityId: this.act.id
  927. }, res => {
  928. requsetmessage.remind();
  929. req.msg('预约成功');
  930. this.setData({
  931. isRemind: true
  932. });
  933. });
  934. },
  935. cancelActivityRemind(event) {
  936. if (req.header.appId == 'ZQ1VK5oc17I387E') {
  937. } else {
  938. req.postRequest('/api/activity/cancel/remind', {
  939. id: this.act.id
  940. }, res => {
  941. req.msg('取消预约成功');
  942. this.setData({
  943. isRemind: false
  944. });
  945. });
  946. }
  947. },
  948. showTab: function(e) {
  949. this.setData({
  950. tabIndex: e.detail
  951. });
  952. },
  953. scoreTab: function(e) {
  954. this.form.page = 0;
  955. this.setData({
  956. current: e.detail,
  957. ['form.page']: 1
  958. });
  959. },
  960. freshenFun: function(e) {
  961. this.setData({
  962. freshen: e.detail
  963. });
  964. },
  965. // 获取品种保证
  966. getGuarantee() {
  967. return new Promise((data, rej) => {
  968. req.getRequest('/api/config', {}, res => {
  969. req.setStorage("configRes", JSON.stringify(res))
  970. this.about = res
  971. data(res)
  972. if (this.merchant && this.merchant.isDefault == 1 || this.query.acid) {
  973. // 切割;拿到数组,然后在过滤掉空值
  974. if (res.b2c_service_guarantee && res.b2c_service_guarantee != null) {
  975. this.setData({
  976. guarantee: res.b2c_service_guarantee.split(";").filter(it => {
  977. return it = it && it.trim();
  978. })
  979. });
  980. }
  981. } else {
  982. if (res.o2o_service_guarantee && res.b2c_service_guarantee != null) {
  983. this.setData({
  984. guarantee: res.o2o_service_guarantee.split(";").filter(it => {
  985. return it = it && it.trim();
  986. })
  987. });
  988. }
  989. } // if(res.Is_Store_Price_Stock){
  990. // this.setData({Is_Store_Price_Stock:res.Is_Store_Price_Stock})
  991. // }
  992. if (res.is_open_shop) {
  993. this.is_open_shop = res.is_open_shop;
  994. }
  995. if (res.is_open_comments) {
  996. this.setData({
  997. is_open_comments: res.is_open_comments
  998. });
  999. } // 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 })
  1000. });
  1001. })
  1002. },
  1003. // 是否开启小店
  1004. isShop() {
  1005. if (req.getStorage('distribution')) {
  1006. dist = req.getStorage('distribution')
  1007. this.setData({
  1008. distr: dist
  1009. })
  1010. console.log(dist)
  1011. if (dist.distributionSmallShopOpen == 1) {
  1012. req.postRequest('/api/shopBase/isOpenShop', {}, data => {
  1013. this.setData({
  1014. isshop: data
  1015. })
  1016. console.log(data)
  1017. })
  1018. }
  1019. }
  1020. },
  1021. addShop() { //添加到小店
  1022. req.postRequest('/api/shopProduct/save', {
  1023. productId: this.act.id,
  1024. type: 6
  1025. }, data => {
  1026. this.act.isJoinShop = true;
  1027. this.isHide = false;
  1028. })
  1029. },
  1030. hidePop() { //添加到小店
  1031. this.setData({
  1032. isHide: true
  1033. })
  1034. },
  1035. }
  1036. };
  1037. </script>
  1038. <style>
  1039. @import "./newbornDetails.css";
  1040. </style>