index.js 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578
  1. const util = require('../../../utils/util.js');
  2. const app = getApp();
  3. var updateTimer;
  4. Page({
  5. data: {
  6. vip_Info: {},
  7. showGoodsRecom: false,
  8. securityShow: '', //安全保障
  9. physicalForCardTitle: '点击查看活动前所需准备的物品',
  10. countDown: { //倒计时任务
  11. show: false,
  12. time: 20,
  13. taskId: ''
  14. },
  15. show: {
  16. chat: false,
  17. sku: false,
  18. growup: false,
  19. tips: false,
  20. official: false
  21. },
  22. showConvert: false, //特权兑换弹窗
  23. checkedTime: 5, //选中时间
  24. city: '', //选中城市
  25. showNextConvert: false, //特权兑换二次提醒弹窗
  26. showPaymentPopup: false, //支付尾款弹窗
  27. showEnrollPopup: false, //邀请报名弹窗
  28. showAlternatePopup: false, //候补弹窗
  29. showGrouPopup: false, //拼团弹窗
  30. channel: 0, //渠道码
  31. channelTimes: 0, //渠道码分享次数
  32. isBuy: true,
  33. copyCanbuy: 1, //用于预售存储会员是否可购买字段
  34. aid: '',
  35. title: '',
  36. groupid: '', //拼团id
  37. orderid: '', //拼团才有的订单id
  38. current: 0,
  39. buttonText: "",
  40. buttonClass: "button-theme",
  41. buttonClass1: "button-theme",
  42. buttonPTClass: "button-danger",
  43. showTimer: false,
  44. processTimer: null,
  45. privilegeTime: 0,
  46. getBalanceData: true,
  47. showPrivilege: true,
  48. updateTime: {
  49. isPayInfo: true
  50. },
  51. datas: {},
  52. score: 0,
  53. comments: [], //评论
  54. imgUrl: util.config.imgPath,
  55. userInfo: {},
  56. viode: [], //视频
  57. isColumn: false, //导航条是否到顶部
  58. datasetHeight: 0, //目标节点的高度
  59. showBack: false, //是否显示返回顶部
  60. temCountId: '',
  61. total: 0,
  62. onshow: true,
  63. url: "/",
  64. isScroll: false,
  65. officialText: '',
  66. baseStatus: '',
  67. remainTime: {},
  68. CompletedOrderInfo: {},
  69. alternateData: {},
  70. alternateBol: true,
  71. marvellousList: [], //活动详情往期精彩列表
  72. shareInfo: {
  73. sid: '',
  74. pid: '',
  75. sharer: '',
  76. groupid: '',
  77. sessionName: '',
  78. mealsName: ''
  79. },
  80. inviteEnroll: false, //是否参与拼团及同场次排期
  81. refundShow: false,
  82. type: 0,
  83. detailParams: {},
  84. autoplay: false, //自动播放
  85. shareInvite: '',//分享过来的邀请码(用于非机构用户二次分享)
  86. },
  87. // 点击往期精彩后跳转
  88. goPrevious(e) {
  89. console.log(e);
  90. let psId = e.currentTarget.dataset.psid
  91. console.log(psId);
  92. wx.navigateTo({
  93. url: '/pages/product/Previous/index?psId=' + JSON.stringify(psId) + '&aid=' + this.data.datas.aid,
  94. })
  95. },
  96. // 点击安全保障
  97. jumpPage(e) {
  98. wx.navigateTo({
  99. url: '/pages/product/security/index?id=' + JSON.stringify(this.data.securityShow),
  100. })
  101. },
  102. jumpGoodsPage() {
  103. wx.navigateTo({
  104. url: '/pages/public/showGoodsList/index?aid=' + this.data.aid,
  105. })
  106. },
  107. onLoad(options) {
  108. console.log('options', options)
  109. if (!util.isEmpty(options.sharesid)) {
  110. this.setData({
  111. 'shareInfo.sid': options.sharesid,
  112. 'shareInfo.pid': options.sharepid,
  113. 'shareInfo.sharer': options.sharer,
  114. 'shareInfo.groupid': util.isEmpty(options.groupid) || options.groupid == 'undefined' || options.groupid == 'null' ? '' : options.groupid
  115. })
  116. if (!util.config.invitePopupTime) {
  117. util.config.invitePopupTime = true;
  118. }
  119. }
  120. this.setData({
  121. showPopup: options.showPopup
  122. })
  123. let aid = options.aid,
  124. orderid = options.orderid || '',
  125. groupid = util.isEmpty(options.groupid) || options.groupid == 'undefined' || options.groupid == 'null' ? '' : options.groupid,
  126. that = this;
  127. if (options.invite) {
  128. wx.setStorageSync("WX-invite", options.invite);
  129. this.setData({
  130. shareInvite: options.invite
  131. })
  132. // this.isRecomCode()
  133. }
  134. if (options.channel) {
  135. this.setData({
  136. channel: options.channel,
  137. channelTimes: options.channelTimes || 1
  138. })
  139. util.config.channelInfo = {
  140. channel: options.channel,
  141. channelTimes: options.channelTimes || 1
  142. }
  143. this.getChannelMsg(options)
  144. }
  145. if (!options.channel && util.config.channelInfo.channel) {
  146. let getChannel = util.config.channelInfo.channel;
  147. this.setData({
  148. channel: getChannel.channel,
  149. channelTimes: getChannel.channelTimes
  150. })
  151. this.getChannelMsg(getChannel)
  152. }
  153. this.setData({
  154. aid: aid,
  155. orderid: orderid,
  156. groupid: !util.isEmpty(groupid) ? groupid : '',
  157. userInfo: app.globalData.userInfo
  158. })
  159. util.refreshCount();
  160. // —————————————— 从二维码扫码进去活动详情页面 ——————————————————
  161. if (!util.isEmpty(options.scene)) {
  162. // let scene = decodeURIComponent(options.scene);
  163. let pa = this.getSceneParam(options.scene);
  164. if (util.isObjEmpty(pa)) {
  165. util.showTips("二维码已过期,请重新获取!");
  166. this.setData({
  167. onshow: false
  168. });
  169. return false;
  170. }
  171. if (!util.isEmpty(pa.paramsCode)) { //code不为空时,通过code获取对应活动分享参数
  172. this.setData({
  173. onshow: false
  174. });
  175. util.ajax({
  176. func: "params",
  177. data: {
  178. "code": pa.paramsCode
  179. },
  180. load: false
  181. }, function (res) {
  182. if (res.code == 0 && !util.isEmpty(res.data)) {
  183. if (!util.isEmpty(res.data.code)) {
  184. wx.setStorageSync("WX-invite", res.data.code);
  185. // that.isRecomCode() //通过邀请码判断邀请者身份
  186. }
  187. aid = res.data.aid || '';
  188. groupid = util.isEmpty(res.data.groupid) || res.data.groupid == 'undefined' || res.data.groupid == 'null' ? '' : res.data.groupid;
  189. orderid = res.data.orderid || '';
  190. that.setData({
  191. aid,
  192. orderid,
  193. groupid,
  194. 'shareInfo.sid': res.data.sharesid || '',
  195. 'shareInfo.pid': res.data.sharepid || '',
  196. 'shareInfo.sharer': res.data.sharer || '',
  197. 'shareInfo.groupid': groupid,
  198. });
  199. that.saveAndSendCode(res.data);
  200. // util.promise().then(function (value) {
  201. that.getData();
  202. // });
  203. }
  204. });
  205. } else {
  206. if (!util.isEmpty(pa.aid)) {
  207. util.codeGetAid(pa.aid).then(res => {
  208. that.setData({
  209. aid: res.data
  210. })
  211. })
  212. } else {
  213. wx.reLaunch({
  214. url: '/pages/home/index'
  215. });
  216. }
  217. }
  218. } else if (util.isEmpty(aid)) {
  219. wx.reLaunch({
  220. url: 'pages/home/index'
  221. });
  222. return false;
  223. }
  224. // this.isRecomCode()
  225. },
  226. // 点击无忧报名弹框中确定
  227. closeRefund() {
  228. this.setData({
  229. refundShow: false
  230. })
  231. },
  232. // 点击报名无忧事件
  233. changeRefund() {
  234. console.log(Number(this.data.datas.refundRule));
  235. this.setData({
  236. refundShow: true,
  237. type: Number(this.data.datas.refundRule)
  238. })
  239. },
  240. getSceneParam(e) {
  241. if ((e != undefined || e != '') && e.indexOf('urlcode') == -1) {
  242. let scene = decodeURIComponent(e),
  243. data = {};
  244. if (scene.indexOf(",") != -1) {
  245. let params = scene.split(',');
  246. for (let i in params) {
  247. var val = params[i].split('=');
  248. val.length > 0 && val[0] && (data[val[0]] = val[1] || null)
  249. }
  250. return data;
  251. } else {
  252. if (scene.indexOf('paramsCode') != -1) {
  253. let val = scene.split('=');
  254. data[val[0]] = val[1];
  255. } else {
  256. data.aid = scene;
  257. }
  258. return data;
  259. }
  260. } else {
  261. return {};
  262. }
  263. let data = {};
  264. for (let i in params) {
  265. var val = params[i].split('=');
  266. val.length > 0 && val[0] && (data[val[0]] = val[1] || null)
  267. }
  268. return data;
  269. },
  270. openConvertPopup() {
  271. this.setData({
  272. showConvert: true
  273. })
  274. },
  275. closeConvertPopup() {
  276. this.setData({
  277. showConvert: false,
  278. showNextConvert: false
  279. })
  280. },
  281. // 任务倒计时完成
  282. finishedTime() {
  283. this.setData({
  284. 'countDown.show': false
  285. })
  286. },
  287. // 宝贝币最高可兑换时长
  288. maxPrivilegeTime(e) {
  289. this.maxTime = e.time && e.time > 0 ? e.time : 0;
  290. },
  291. // 获取特权兑换时长
  292. changePrivilege(e) {
  293. this.closeConvertPopup()
  294. this.getData()
  295. },
  296. // 兑换二次提醒
  297. showPrompt(e) {
  298. this.setData({
  299. showConvert: false,
  300. checkedTime: e.detail.checkedTime,
  301. showNextConvert: true
  302. })
  303. },
  304. // 关闭二次弹窗
  305. closeNextPopup() {
  306. this.setData({
  307. showNextConvert: false,
  308. })
  309. },
  310. // 获取分享家是否停用
  311. stat() {
  312. // console.log(this.data.userInfo.roleType);
  313. // console.log(this.data.datas.shareCommission);
  314. let that = this;
  315. if (!util.isObjEmpty(this.data.userInfo)) {
  316. util.stat().then(res => {
  317. let data = util.getCoinLevel(res.allCoin)
  318. that.setData({
  319. 'userInfo.shareStatus': res.shareStatus,
  320. showfloatWin: that.data.userInfo.roleType == 'sharer' && that.data.userInfo.shareStatus == 1 && that.data.datas.shareCommission > 0 && that.data.datas.rebate != 1 ? true : false,
  321. vip_Info: data
  322. })
  323. })
  324. }
  325. },
  326. // 通过小程序码进入的获取活动aid
  327. codeGetAid(aid) {
  328. let that = this;
  329. util.ajax({
  330. func: "v2/article/aid",
  331. data: {
  332. "aid": aid
  333. }
  334. }, function (res) {
  335. if (res.code == 0) {
  336. that.setData({
  337. aid: res.data
  338. })
  339. }
  340. });
  341. },
  342. // 支付尾款弹窗(继续报名)
  343. paymentPay(e) {
  344. if (this.data.inviteEnroll) {
  345. let data = {
  346. type: "makeUpGroup",
  347. currentTarget: {
  348. dataset: {
  349. alone: "0",
  350. item: {
  351. sid: this.data.shareInfo.sessionName ? this.data.shareInfo.sid : -1,
  352. pid: this.data.shareInfo.sessionName ? this.data.shareInfo.pid : -1
  353. }
  354. }
  355. }
  356. //套餐选中取决于场次有无
  357. }
  358. this.goPay(data)
  359. } else {
  360. this.goPay(e)
  361. }
  362. },
  363. // 点击评论跳转至全部评论页
  364. showAllComment() {
  365. wx.navigateTo({
  366. url: '/pages/product/comment/index?aid=' + this.data.datas.aid,
  367. })
  368. },
  369. // 候补弹窗
  370. alternateEmit(e) {
  371. let data = e.detail;
  372. this.setData({
  373. 'show.sku': false,
  374. showAlternatePopup: true,
  375. alternateData: data
  376. })
  377. },
  378. // 关闭拼团弹窗
  379. closeGroupPopup(e) {
  380. this.setData({
  381. showGrouPopup: e.detail
  382. })
  383. },
  384. // 关闭约伴邀请拼团弹窗(我再看看)
  385. closeinviteEnroll() {
  386. util.config.invitePopupTime = false;
  387. this.setData({
  388. showEnrollPopup: false,
  389. inviteEnroll: false,
  390. isBuy: false
  391. })
  392. },
  393. // 约伴邀请弹窗(同场次及拼团)
  394. inviteEnrollSignup() {
  395. util.config.invitePopupTime = false;
  396. this.setData({
  397. showEnrollPopup: false,
  398. inviteEnroll: true,
  399. isBuy: true
  400. })
  401. this.goPay({
  402. type: "inviteEnroll",
  403. currentTarget: {
  404. dataset: {
  405. alone: '1',
  406. item: {
  407. sid: this.data.shareInfo.sid,
  408. pid: this.data.shareInfo.pid,
  409. }
  410. }
  411. }
  412. })
  413. },
  414. // 通过邀请码判断邀请者身份
  415. isRecomCode() {
  416. let that = this,
  417. code = wx.getStorageSync("WX-invite");
  418. if (!util.isEmpty(code) && !app.globalData.userInfo) {
  419. util.ajax({
  420. func: "inviter/info",
  421. data: {
  422. "code": code
  423. }
  424. }, function (res) {
  425. if (res.code == 0) {
  426. if (res.data.roleType == 'sharer' || res.data.roleType == 'organ') {
  427. clearTimeout(updateTimer);
  428. let updateTimer = setTimeout(() => {
  429. wx.navigateTo({
  430. url: '/pages/home/login'
  431. });
  432. }, 1000);
  433. }
  434. }
  435. });
  436. }
  437. },
  438. // 返回首页
  439. gohome() {
  440. wx.reLaunch({
  441. url: '/pages/home/index',
  442. })
  443. },
  444. // 扫二维码存储并传递渠道码参数值
  445. saveAndSendCode(params) {
  446. console.log('channel', params)
  447. let arr = params,
  448. op = {}; //格式转换
  449. op.channel = params.channelId;
  450. op.channelTimes = params.channelCount;
  451. this.getChannelMsg(op); //创建渠道记录
  452. if (op.channel) {
  453. this.setData({
  454. channel: op.channel,
  455. channelTimes: op.channelTimes ? op.channelTimes : 1
  456. })
  457. util.config.channelInfo = {
  458. channel: op.channel,
  459. channelTimes: op.channelTimes ? op.channelTimes : 1
  460. }
  461. return false;
  462. }
  463. if (!op.channel && !op.channelTimes && util.config.channelInfo.channel != 0) {
  464. let getChannel = util.config.channelInfo;
  465. if (getChannel.channel) {
  466. this.setData({
  467. channel: getChannel.channel,
  468. channelTimes: getChannel.channelTimes
  469. })
  470. return false;
  471. } else {
  472. this.setData({
  473. channelTimes: 0
  474. })
  475. }
  476. }
  477. },
  478. // 跳转至表单详情页(支付尾款)
  479. jumpBalancePayment(e) {
  480. let that = this;
  481. this.setData({
  482. showPaymentPopup: false
  483. })
  484. if (this.data.CompletedOrderInfo.status == 1) {
  485. wx.navigateTo({
  486. url: '/pages/product/balancePayment/balancePayment?aid=' + that.data.aid + '&otype=1' + '&orderid=' + that.data.CompletedOrderInfo.orderid + '&presellstatus=' + (this.data.CompletedOrderInfo.status != 0 ? 1 : 0),
  487. })
  488. }
  489. if (this.data.CompletedOrderInfo.status == 2) {
  490. wx.navigateTo({
  491. url: '/pages/order/index/order?otype=1',
  492. })
  493. }
  494. },
  495. // 详情页调用渠道创建记录接口
  496. getChannelMsg(options) {
  497. if (options.channel) {
  498. let channelParam = options.channel,
  499. that = this;
  500. util.getChannelMsg(channelParam).then((res) => { });
  501. }
  502. },
  503. // 获取是否显示尾款信息
  504. getBalance() {
  505. let that = this;
  506. util.ajax({
  507. func: "v2/article/presellOrder",
  508. data: {
  509. "aid": that.data.aid
  510. }
  511. }, function (res) {
  512. if (res.code == 0) {
  513. that.setData({
  514. CompletedOrderInfo: res.data
  515. })
  516. }
  517. })
  518. },
  519. onShow() {
  520. // 没有版本字段或字段与写入不一致强制重新登录
  521. if (!app.globalData.userInfo || !app.globalData.userInfo.VERSION || app.globalData.userInfo.VERSION != 9) {
  522. // 静默登录
  523. util.silentLogin().then(res => { })
  524. }
  525. var that = this
  526. // getLocation = util.promise();
  527. this.safetyTip(this.data.showPopup);
  528. this.setData({
  529. showConvert: false,
  530. showNextConvert: false
  531. })
  532. setTimeout(() => {
  533. if (that.data.onshow) {
  534. if (!util.isObjEmpty(app.globalData.city)) {
  535. that.getData();
  536. } else {
  537. // getLocation.then(function (value) {
  538. that.getData();
  539. // });
  540. }
  541. }
  542. }, 800);
  543. },
  544. safetyTip(showPopup) {
  545. let that = this,
  546. safeTips = wx.getStorageSync("safeTips"),
  547. getInfo = {};
  548. util.ajax({
  549. func: 'v2/index/advert/popup',
  550. load: false
  551. }, function (res) {
  552. if (res.code == 0) {
  553. // 不使用接口返回,展示默认
  554. // getInfo.data = res.data;
  555. getInfo.entryPage = 'articleInfo';
  556. getInfo.showPopup = (showPopup == 0 ? false : true) || true;
  557. that.safeTip = that.selectComponent('#safeTip');
  558. that.safeTip.getSafeTips(getInfo);
  559. }
  560. })
  561. this.data.show.tips = safeTips.show;
  562. this.setData({
  563. show: this.data.show
  564. });
  565. },
  566. onUnload() {
  567. this.pageCount();
  568. this.setData({
  569. show: this.defaultShow(),
  570. 'countDown.show': false
  571. });
  572. clearTimeout(this.data.processTimer);
  573. },
  574. onHide() {
  575. this.pageCount();
  576. this.setData({
  577. show: this.defaultShow(),
  578. 'countDown.show': false
  579. });
  580. },
  581. skuClose(e) {
  582. this.data.show.sku = e.detail;
  583. this.setData({
  584. show: this.data.show
  585. });
  586. },
  587. defaultShow() {
  588. this.data.show = {
  589. chat: false,
  590. sku: false,
  591. tips: false,
  592. growup: false,
  593. official: false
  594. };
  595. return this.data.show;
  596. },
  597. onPageScroll(e) {
  598. var query = wx.createSelectorQuery();
  599. var isColumn = this.data.isColumn,
  600. that = this,
  601. showBack = this.data.showBack;
  602. query.select('#content').boundingClientRect();
  603. query.select('#safeTrip').boundingClientRect();
  604. query.select('#notes').boundingClientRect();
  605. query.exec(function (res) {
  606. if (res && !that.data.isScroll) {
  607. if (res[2].top <= 0) {
  608. that.setData({
  609. current: 2
  610. });
  611. } else if (res[1].top <= 0) {
  612. that.setData({
  613. current: 1
  614. });
  615. } else if (res[0].top <= 37) {
  616. that.setData({
  617. current: 0
  618. });
  619. }
  620. that.setData({
  621. isColumn: res[0].top <= 0 ? true : false
  622. });
  623. }
  624. });
  625. if (e.scrollTop > 500 && !showBack) {
  626. this.setData({
  627. showBack: true
  628. })
  629. } else if (e.scrollTop <= 500 && showBack) {
  630. this.setData({
  631. showBack: false
  632. })
  633. }
  634. },
  635. chooseNav(e) {
  636. let current = e.currentTarget.dataset.id,
  637. that = this;
  638. that.setData({
  639. current,
  640. isScroll: true
  641. });
  642. var arr = ['content', 'safeTrip', 'notes'];
  643. wx.pageScrollTo({
  644. selector: "#" + arr[current],
  645. success: () => {
  646. that.setData({
  647. isColumn: true
  648. });
  649. clearTimeout(updateTimer);
  650. let updateTimer = setTimeout(() => {
  651. that.setData({
  652. isScroll: false
  653. });
  654. }, 1000);
  655. }
  656. });
  657. let reportStr;
  658. switch (current) {
  659. case 0:
  660. reportStr = "active_tips";
  661. break;
  662. case 1:
  663. reportStr = "safe_trip";
  664. break;
  665. case 2:
  666. reportStr = "active_instructions";
  667. break;
  668. }
  669. wx.reportAnalytics(reportStr, {
  670. aid: that.data.aid,
  671. title: that.data.title,
  672. });
  673. },
  674. getData() {
  675. let that = this,
  676. userInfo = app.globalData.userInfo;
  677. util.ajax({
  678. func: "v2/article/detail",
  679. data: {
  680. "aid": that.data.aid,
  681. "groupid": (that.data.groupid != 'null' ? that.data.groupid : ''),
  682. 'orderid': that.data.orderid || ''
  683. },
  684. load: false
  685. }, function (res) {
  686. if (res.code == 0) {
  687. let datas = res.data;
  688. that.data.paramsDetail = res.data.psId
  689. datas.isTuan = datas.discountStatus;
  690. that.setData({
  691. securityShow: datas.articleType ? datas.articleType : '',
  692. copyCanbuy: datas.canbuy,
  693. privilegeTime: datas.aheadTimeLong ? that.timeToDate(datas.aheadTimeLong) : 0,
  694. 'shareInfo.groupid': !util.isEmpty(datas.gdiscount.groupid) ? datas.gdiscount.groupid : '',
  695. marvellousList: datas.productSystemHistoryList
  696. })
  697. console.log(that.data.marvellousList);
  698. that.setData({
  699. baseStatus: datas.status,
  700. buttonText: util.decode(datas.status, 0, (!util.isObjEmpty(res.data.gdiscount) ? (!util.isEmpty(that.data.groupid) ? '立即购买' : "单独报名") : (userInfo && userInfo.membered == 1 ? "会员报名" : "立即报名")), 1, "已结束", 2, "已满额", 3, "已下架", 4, "待审核", 6, "未开始", "")
  701. });
  702. let buttonClass = '',
  703. buttonClass1 = '',
  704. buttonPTClass = '';
  705. if (datas.presellOpen != 0) {
  706. datas.canbuy = 1;
  707. buttonClass = datas.presellOpen == 1 ? 'button-theme' : 'disabled';
  708. buttonClass1 = (datas.gdiscount.items && datas.gdiscount.status == 0 && datas.presellOpen == 1) ? 'button-theme' : 'disabled';
  709. } else {
  710. buttonClass = datas.status == 0 ? (datas.gdiscount.items || datas.gdiscount.status == 0 ? 'button-theme' : 'button-theme') : 'disabled';
  711. buttonClass1 = (datas.status == 0) ? ((datas.gdiscount.items && datas.gdiscount.status == 0) ? 'button-theme' : 'disabled') : 'disabled';
  712. buttonPTClass = datas.status == 0 && datas.canbuy == 0 ? (datas.gdiscount.items || datas.gdiscount.status == 0 ? 'button-danger' : 'button-danger') : 'disabled';
  713. }
  714. if (!util.isObjEmpty(datas.users)) {
  715. for (let i in datas.users) {
  716. datas.users[i].avatar = !util.isEmpty(datas.users[i].avatar) ? datas.users[i].avatar : '/images/default_logo.jpg';
  717. }
  718. }
  719. res.data.role = userInfo && userInfo['role'] ? userInfo['role'] : util.userRole(Math.round(res.data.score));
  720. res.data.sdiscountText = res.data.sdiscount ? res.data.sdiscount.toString().replace("0.", "") : '';
  721. console.log(datas, '数据')
  722. // 分成两行
  723. if (datas.tags && datas.tags.length >= 5) {
  724. const middleIndex = Math.ceil(datas.tags.length / 2);
  725. datas.tags1 = datas.tags.splice(0, middleIndex);
  726. datas.tags2 = datas.tags.splice(-middleIndex);
  727. } else {
  728. datas.tags1 = datas.tags;
  729. }
  730. console.log(datas.tags1, datas.tags2);
  731. that.setData({
  732. city: res.data.city,
  733. datas,
  734. buttonClass,
  735. buttonClass1,
  736. buttonPTClass,
  737. title: datas.title,
  738. currentPages: getCurrentPages().length,
  739. groupid: datas.gdiscount.groupid ? datas.gdiscount.groupid : that.data.groupid,
  740. growupInfo: {
  741. otype: (datas.gdiscount ? datas.gdiscount.otype : 0),
  742. price: (datas.gdiscount ? datas.gdiscount.maxGPrice : 0.00),
  743. type: (datas.gdiscount ? datas.gdiscount.type : 0),
  744. createGroup: 0 //1--新开拼团 0--一键参团
  745. },
  746. integralConfig: {
  747. discount: datas.discount,
  748. aid: datas.aid
  749. },
  750. showPrivilege: (datas.presellOpen == 2 || (datas.presellOpen == 0 && datas.status == 6) ? true : false)
  751. });
  752. if (((datas.showStartTimer == 1 || datas.showEndTimer == 1)) || (datas.presellOpen != 0 && (datas.showPresellStartTimer == 1 || datas.showPresellEndTimer == 1))) {
  753. that.updateTime();
  754. }
  755. console.log(datas.qptype);
  756. // console.log(datas.qptype, datas.showStartTimer, datas.showEndTimer, datas.presellOpen, datas.showPresellStartTimer, datas.showPresellEndTimer);
  757. // console.log(datas.qptype == 1 && (datas.showStartTimer == 0 && datas.showEndTimer == 0));
  758. if (((datas.showStartTimer == 0 && datas.showEndTimer == 0)) || (datas.presellOpen != 0 && (datas.showPresellStartTimer == 1 || datas.showPresellEndTimer == 1))) {
  759. that.updateTime();
  760. }
  761. // if ((datas.qptype == 1 && (datas.saleTimeLong >0 || datas.endSaleTimeLong >0)) || (datas.presellOpen != 0 && (datas.presellStartTimeLong >0 || datas.presellEndTimeLong >0))) {
  762. // that.updateTime();
  763. // }
  764. if (datas.presellOpen == 0) {
  765. that.getBalance();
  766. }
  767. that.remainTime();
  768. that.getSkuInfo();
  769. that.getFeedbook();
  770. that.getContent();
  771. that.pageCount();
  772. that.stat();
  773. that.getGoodsRecommend();
  774. that.countDownTask();
  775. } else {
  776. util.showTips(res.reason);
  777. }
  778. })
  779. },
  780. getGoodsRecommend() {
  781. let that = this;
  782. util.getGoodsRecommend(this.data.datas.aid).then(res => {
  783. that.setData({
  784. showGoodsRecom: res
  785. })
  786. })
  787. },
  788. // 宝贝币任务倒计时
  789. countDownTask() {
  790. let that = this;
  791. let oldData = wx.getStorageSync('task_viewAct'),
  792. nowDate = util.getNowFormatDate();
  793. if (nowDate && oldData.date == nowDate) {
  794. let timer = setTimeout(() => {
  795. util.ajax({
  796. func: "v2/user_coin/task/detail",
  797. data: {
  798. code: 'browseArticle'
  799. },
  800. load: false
  801. }, function (res) {
  802. if (res.code == 0) {
  803. if (res.data.passCount < res.data.maxPassCount) {
  804. that.setData({
  805. 'countDown.show': true,
  806. 'countDown.taskId': res.data.id
  807. })
  808. }
  809. clearTimeout(timer)
  810. }
  811. })
  812. }, 1000);
  813. }
  814. },
  815. // 特权时间
  816. timeToDate(time) {
  817. var date = new Date();
  818. if (time) {
  819. date.date = Math.floor(time / (1000 * 60 * 60 * 24));
  820. date.hours = Math.floor((time / (1000 * 60 * 60)) % 24);
  821. date.minutes = Math.floor((time / (1000 * 60)) % 60);
  822. if (date.date <= 0 && date.hours > 0) {
  823. return date.hours + '小时' + date.minutes + '分钟';
  824. } else if (date.date <= 0 && date.hours <= 0 && date.minutes > 0) {
  825. return date.minutes + '分钟';
  826. } else {
  827. return date.date + '天' + date.hours + '小时' + date.minutes + '分钟';
  828. }
  829. } else {
  830. return 0;
  831. }
  832. },
  833. // 拼团剩余时间数据处理
  834. remainTime() {
  835. let self = this,
  836. data = this.data.datas,
  837. lag = data.gdiscount.times / 1000;
  838. data.remainTime = {};
  839. data.remainTime.day = Math.floor(lag / (3600 * 24));
  840. let mo = lag % (3600 * 24);
  841. data.remainTime.hour = Math.floor(mo / 3600);
  842. mo = mo % 3600;
  843. data.remainTime.minite = Math.floor(mo / 60);
  844. data.remainTime.second = Math.floor(mo % 60);
  845. data.remainTime.hour = isTimeLeng(data.remainTime.hour);
  846. data.remainTime.minite = isTimeLeng(data.remainTime.minite);
  847. data.remainTime.second = isTimeLeng(data.remainTime.second);
  848. data.gdiscount.times = data.gdiscount.times - 1000;
  849. self.setData({
  850. remainTime: data.remainTime
  851. });
  852. clearTimeout(updateTimer);
  853. let updateTimer = setTimeout(function () {
  854. self.remainTime();
  855. }, 1000);
  856. function isTimeLeng(val) {
  857. var s = val.toString();
  858. return s.length == 1 ? "0" + val : val;
  859. }
  860. },
  861. getContent() {
  862. let that = this;
  863. util.ajax({
  864. func: "v2/article/content",
  865. data: {
  866. "aid": that.data.aid
  867. },
  868. load: false
  869. }, function (res) {
  870. if (res.code == 0) {
  871. let datas = res.data;
  872. that.data.datas.content = datas.content.replace(/section/g, "div");
  873. that.data.datas.content = that.data.datas.content.replace(/<img/g, "<img style='max-width:100%'");
  874. //datas.content = datas.content.replace(/<!--[^%]*-->/g, "");
  875. let str = datas.content.match(/<source src="(\S*)"/g);
  876. if (str) {
  877. let viode = [];
  878. for (let i in str) {
  879. if (i < 3) { //只显示三个视频
  880. let src = str[i].match(/<source src="(\S*)"/)[1];
  881. viode.push(src.toString())
  882. }
  883. }
  884. that.setData({
  885. viode
  886. });
  887. }
  888. that.data.datas.notes = datas.notes ? datas.notes.replace(/section/g, "div") : '';
  889. that.data.datas.notes = that.data.datas.notes.replace(/<img/g, "<img style='max-width:100%'");
  890. that.data.datas.safeTrip = datas.safeTrip ? datas.safeTrip.replace(/section/g, "div") : '';
  891. that.data.datas.safeTrip = that.data.datas.safeTrip.replace(/<img/g, "<img style='max-width:100%'");
  892. // console.log(that.data.datas.safeTrip);
  893. // console.log(that.data.datas.notes);
  894. // console.log(that.data.datas.content);
  895. that.setData({
  896. datas: that.data.datas
  897. });
  898. }
  899. })
  900. },
  901. getFeedbook() { //获取评论
  902. let that = this;
  903. util.ajax({
  904. func: "comments/list",
  905. data: {
  906. "aid": this.data.aid,
  907. "pageIndex": 1,
  908. "pageSize": 1,
  909. "sort": 1,
  910. "keyword": ''
  911. }
  912. }, function (res) {
  913. if (res.code == 0) {
  914. for (let i in res.data.comments) {
  915. res.data.comments[i].contented = res.data.comments[i].content.replace(/#([^#]+)#/g, "").replace(/<br\/>/g, '\n');
  916. res.data.comments[i].option = res.data.comments[i].content.match(/#([^#]+)#/g);
  917. res.data.comments[i].fcontent = res.data.comments[i].fcontent.replace(/<br\/>/g, '\n');
  918. }
  919. that.setData({
  920. comments: res.data,
  921. score: res.data.score
  922. });
  923. } else {
  924. util.showTips(res.reason);
  925. }
  926. })
  927. },
  928. setRemind(e) {
  929. console.log(e)
  930. if (e.type == "salesReminder") {
  931. this.data.show.growup = false;
  932. }
  933. let that = this;
  934. wx.showModal({
  935. content: this.data.datas.status == 6 ? `确定设置提醒?活动${that.data.datas.presellOpen == 0 ? '开售' : '预售'}前通过小程序或短信通知您。` : '确定设置提醒?活动有名额时通过小程序或短信通知您。',
  936. confirmColor: '#EE3A43',
  937. success: function (res) {
  938. if (res.confirm) {
  939. util.requestMsg('hv74W2gdjlzupQGuN_BgFpyv7VDQxuXf9YhdxlR8His').then(e => {
  940. util.ajax({
  941. func: "v2/articleRemind/confirm",
  942. data: {
  943. aid: that.data.datas.aid,
  944. saleType: that.data.datas.presellOpen == 0 ? 0 : 1
  945. }
  946. }, function (res) {
  947. if (res.code == 0) {
  948. // that.data.show.official = true;
  949. // that.data.officialText = data.data.msg;
  950. // that.setData({ show: that.data.show, officialText: that.data.officialText});
  951. util.showTips(res.data.msg);
  952. } else
  953. util.showTips(res.reason);
  954. });
  955. })
  956. }
  957. }
  958. });
  959. },
  960. gofriend() {
  961. let that = this;
  962. if (util.isEmpty(that.data.aid)) {
  963. util.showTips('aid不存在');
  964. return false;
  965. }
  966. wx.reportAnalytics('together_proper', {
  967. aid: that.data.aid,
  968. title: that.data.datas.title,
  969. });
  970. wx.navigateTo({
  971. url: '/pages/product/activity/partner?aid=' + that.data.aid
  972. })
  973. },
  974. // 活动倒计时
  975. updateTime() {
  976. var self = this,
  977. that = this.data.datas,
  978. userInfo = app.globalData.userInfo,
  979. member_time = 0,
  980. lag = '',
  981. lag2 = '',
  982. memberSale = false;
  983. if (that.presellOpen == 0) { //开售未开始 提前时间
  984. member_time = (!util.isEmpty(that.memberSaleTime) ? that.memberSaleTime / 1000 : null); //会员提前时间
  985. }
  986. if (that.presellOpen == 2) { //预售未开始 提前时间
  987. let t = that.presellStartTimeLong - that.aheadTimeLong;
  988. member_time = ((that.presellStartTimeLong && that.aheadTimeLong) ? t : 0) / 1000;
  989. }
  990. // 设定倒计时时间
  991. if (that.presellOpen == 0) { //正常开售
  992. self.setData({
  993. 'datas.canbuy': self.data.copyCanbuy
  994. })
  995. lag = 0;
  996. lag2 = 0;
  997. lag = (that.saleTimeLong ? that.saleTimeLong : 0) / 1000,
  998. lag2 = (that.endSaleTimeLong ? that.endSaleTimeLong : 0) / 1000;
  999. } else { //预售
  1000. lag = 0;
  1001. lag2 = 0;
  1002. lag = (that.presellStartTimeLong ? that.presellStartTimeLong : 0) / 1000,
  1003. lag2 = (that.presellEndTimeLong ? that.presellEndTimeLong : 0) / 1000;
  1004. that.presellPayStartTime = util.formatDate(util.formatUnixtimestamp(that.saleTime), 'MM月dd日 hh:mm', false);
  1005. that.presellPayEndTime = util.formatDate(util.formatUnixtimestamp(that.presellPaymentDeadline), 'MM月dd日 hh:mm', false);
  1006. }
  1007. let second, minite, hour, day,
  1008. buttonClass = self.data.buttonClass,
  1009. buttonPTClass = self.data.buttonPTClass,
  1010. buttonText = self.data.buttonText,
  1011. buttonClass1 = self.data.buttonClass1;
  1012. if (lag > 0) { //距离开始
  1013. this.setData({
  1014. showPrivilege: true
  1015. })
  1016. day = Math.floor(lag / (3600 * 24));
  1017. let mo = lag % (3600 * 24);
  1018. hour = Math.floor(mo / 3600);
  1019. mo = mo % 3600;
  1020. minite = Math.floor(mo / 60);
  1021. second = Math.floor(mo % 60);
  1022. self.data.updateTime.title = '距开始';
  1023. self.data.updateTime.isQp = 0;
  1024. if (that.status == 0 || that.status == 6) {
  1025. self.data.updateTime.isPayInfo = true;
  1026. } else {
  1027. self.data.updateTime.isPayInfo = false;
  1028. }
  1029. if (that.presellOpen == 0) {
  1030. self.data.showTimer = that.showStartTimer == 0 ? false : true;
  1031. that.saleTimeLong = that.saleTimeLong - 1000;
  1032. self.data.updateTime.saleTime = util.formatDate(util.formatUnixtimestamp(that.saleTime), 'MM月dd日 hh:mm', false);
  1033. memberSale = true;
  1034. } else {
  1035. self.data.showTimer = that.showPresellStartTimer == 0 ? false : true;
  1036. that.presellStartTimeLong = that.presellStartTimeLong - 1000;
  1037. self.data.updateTime.saleTime = util.formatDate(util.formatUnixtimestamp(that.presellStartTime), 'MM月dd日 hh:mm', false);
  1038. }
  1039. } else if (lag2 > 0 && lag <= 0) { // 距离结束
  1040. this.setData({
  1041. showPrivilege: false
  1042. })
  1043. day = Math.floor(lag2 / (3600 * 24));
  1044. let mo = lag2 % (3600 * 24);
  1045. hour = Math.floor(mo / 3600);
  1046. mo = mo % 3600;
  1047. minite = Math.floor(mo / 60);
  1048. second = Math.floor(mo % 60);
  1049. self.data.updateTime.title = "距结束";
  1050. self.data.updateTime.isQp = 1;
  1051. self.data.updateTime.isPayInfo = true;
  1052. if (that.presellOpen == 0) {
  1053. self.data.showTimer = that.showEndTimer == 0 ? false : true;
  1054. that.endSaleTimeLong = that.endSaleTimeLong - 1000;
  1055. self.data.updateTime.saleTime = util.formatDate(util.formatUnixtimestamp(that.endSaleTime), 'MM月dd日 hh:mm', false);
  1056. if (self.data.getBalanceData) {
  1057. // 倒计时结束刷新页面
  1058. if (!util.isObjEmpty(app.globalData.city)) {
  1059. self.getData();
  1060. } else {
  1061. getLocation.then(function (value) {
  1062. self.getData();
  1063. });
  1064. }
  1065. self.setData({
  1066. getBalanceData: false
  1067. })
  1068. }
  1069. } else {
  1070. self.data.showTimer = that.showPresellEndTimer == 0 ? false : true;
  1071. if (that.presellOpen == 2) {
  1072. that.presellOpen = 1
  1073. let sessionStatus = self.data.sku.sessions.find((el) => (el.status == 0));
  1074. // that.status = sessionStatus?0:2;
  1075. buttonClass = sessionStatus ? 'button-theme' : 'disabled';
  1076. buttonClass1 = sessionStatus ? 'button-theme' : 'disabled';
  1077. }
  1078. that.presellEndTimeLong = that.presellEndTimeLong - 1000;
  1079. self.data.updateTime.saleTime = util.formatDate(util.formatUnixtimestamp(that.presellEndTime), 'MM月dd日 hh:mm', false);
  1080. }
  1081. if (that.status == 0 || that.status == 6) {
  1082. if (that.membered == 1) {
  1083. } else {
  1084. buttonClass = "button-theme";
  1085. buttonPTClass = "button-danger";
  1086. }
  1087. if (self.data.sku && that.presellOpen == 1) {
  1088. let sessionStatus = self.data.sku.sessions.find((el) => (el.status == 0));
  1089. that.status = sessionStatus ? 0 : 2;
  1090. } else {
  1091. that.status = 0;
  1092. }
  1093. if (that.status == 2) {
  1094. buttonText = "已满额";
  1095. }
  1096. if (self.data.baseStatus != 2 && that.presellOpen == 0) buttonText = "立即报名";
  1097. }
  1098. // buttonClass = datas.status == 0 && datas.canbuy == 0 ? (datas.gdiscount.items || datas.gdiscount.status == 0 ? 'button-theme' :'button-theme') : 'disabled';
  1099. } else { //活动结束/预售结束
  1100. if (that.presellOpen == 1) {
  1101. that.presellOpen = 0
  1102. that.canbuy = self.data.copyCanbuy;
  1103. that.status = 6;
  1104. self.data.baseStatus = 6;
  1105. buttonText = "未开始";
  1106. buttonClass = 'disabled';
  1107. buttonClass1 = 'disabled';
  1108. console.log(!util.isEmpty(that.memberSaleTime), that.memberSaleTime)
  1109. member_time = (that.memberSaleTime ? that.memberSaleTime : 0) / 1000;
  1110. // self.setData({'datas.presellOpen':0})
  1111. } else {
  1112. that.qptype = 0;
  1113. that.status = 1;
  1114. buttonText = "已结束";
  1115. if (that.presellOpen == 0) {
  1116. buttonClass = "disabled";
  1117. buttonPTClass = "disabled";
  1118. buttonClass1 = 'disabled'
  1119. }
  1120. }
  1121. }
  1122. that.isTuan = 0;
  1123. if (self.data.baseStatus == 6 && userInfo && (userInfo['role']['level'] > 1 || that.membered == 1 || that.aheadTimeLong > 0) && (that.presellOpen == 0 || that.presellOpen == 2) && that.status == 6) { //会员时间倒计时(距离开始时间开始计时)
  1124. if (member_time != null && member_time <= 0) {
  1125. member_time = 0;
  1126. if (that.presellOpen == 0) {
  1127. buttonClass = "button-theme";
  1128. buttonClass1 = "button-theme";
  1129. buttonPTClass = "button-danger";
  1130. buttonText = !util.isEmpty(self.data.groupid) ? '立即购买' : "单独报名";
  1131. self.data.updateTime.isPayInfo = true;
  1132. that.status = 0;
  1133. // this.getBalance()
  1134. // self.setData({getBalanceData:false})
  1135. } else {
  1136. that.status = 0;
  1137. buttonClass = "button-theme";
  1138. self.data.updateTime.isPayInfo = true;
  1139. }
  1140. self.setData({
  1141. buttonClass: buttonClass,
  1142. buttonPTClass: buttonPTClass,
  1143. buttonText,
  1144. datas: that
  1145. });
  1146. } else {
  1147. // if (that.presellOpen == 0) {
  1148. // that.memberSaleTime = that.memberSaleTime - 1000;
  1149. // }
  1150. }
  1151. }
  1152. if (that.presellOpen != 0 || (that.presellOpen == 0 && that.status == 6) && !util.isEmpty(that.memberSaleTime)) {
  1153. that.memberSaleTime = that.memberSaleTime - 1000;
  1154. }
  1155. if (lag > 0 || lag2 > 0) {
  1156. self.data.updateTime.day = isTimeLeng(day);
  1157. self.data.updateTime.hour = isTimeLeng(hour);
  1158. self.data.updateTime.minite = isTimeLeng(minite);
  1159. self.data.updateTime.second = isTimeLeng(second);
  1160. }
  1161. if (that.status == 0 && (member_time <= 0 || lag <= 0)) {
  1162. that.canbuy = 0;
  1163. that.isTuan = 1;
  1164. }
  1165. let datasPresellOpen = 'datas.presellOpen';
  1166. self.setData({
  1167. datasPresellOpen: that.presellOpen,
  1168. showTimer: self.data.showTimer,
  1169. datas: that,
  1170. updateTime: self.data.updateTime,
  1171. buttonClass: buttonClass,
  1172. buttonPTClass: buttonPTClass,
  1173. buttonClass1: buttonClass1,
  1174. buttonText,
  1175. 'datas.status': that.status
  1176. });
  1177. clearTimeout(self.data.processTimer);
  1178. let updateTimer = setTimeout(function () {
  1179. self.updateTime();
  1180. }, 1000);
  1181. self.setData({
  1182. processTimer: updateTimer
  1183. })
  1184. if (that.presellOpen == 0 && that.status == 1) {
  1185. clearTimeout(self.data.processTimer);
  1186. }
  1187. function isTimeLeng(val) {
  1188. var s = val.toString();
  1189. return s.length == 1 ? "0" + val : val;
  1190. }
  1191. },
  1192. goPay(e) { //点击报名活动
  1193. console.log(e)
  1194. if (!util.isObjEmpty(this.data.CompletedOrderInfo) && this.data.CompletedOrderInfo.status != 0 && (e.type == "tap" || e.type == "inviteEnroll" || e.type == "close")) {
  1195. this.setData({
  1196. showPaymentPopup: true
  1197. })
  1198. } else {
  1199. // if (!util.isEmpty(this.data.groupid)&&!e.detail.pop && this.data.alternateBol && e.type=="tap") {
  1200. // this.setData({showGrouPopup:true})
  1201. // return false;
  1202. // }
  1203. if (this.data.showPaymentPopup) {
  1204. this.setData({
  1205. showPaymentPopup: false
  1206. });
  1207. }
  1208. if (this.data.showGrouPopup) {
  1209. this.setData({
  1210. showGrouPopup: false
  1211. })
  1212. }
  1213. this.data.show = this.defaultShow();
  1214. this.data.show.growup = false;
  1215. this.data.show.integral = false;
  1216. if (this.data.datas.canbuy == 0 && this.data.datas.status == 0) {
  1217. this.data.show.sku = true;
  1218. let data = JSON.stringify(e.currentTarget.dataset) != "{}" ? e.currentTarget.dataset : e.detail;
  1219. this.data.growupInfo.createGroup = data.alone ? data.alone : (this.data.growupInfo.createGroup != undefined ? this.data.growupInfo.createGroup : 0);
  1220. let isBuy = this.data.growupInfo.createGroup == 0 ? false : true;
  1221. this.setData({
  1222. url: '/page/registration.html',
  1223. show: this.data.show,
  1224. isBuy,
  1225. growupInfo: this.data.growupInfo,
  1226. skuIndex: data.alone != 1 && data.item ? data.item.sid : -1,
  1227. mealsIndex: data.alone != 1 && data.item ? data.item.pid : -1,
  1228. });
  1229. }
  1230. }
  1231. },
  1232. // 新开拼团/一键参团弹窗确认购买
  1233. growupToPay(e) {
  1234. if (this.data.inviteEnroll) {
  1235. let data = {
  1236. dataset: {
  1237. alone: this.data.growupInfo.createGroup,
  1238. item: {
  1239. sid: this.data.shareInfo.sessionName ? this.data.shareInfo.sid : -1,
  1240. pid: this.data.shareInfo.sessionName ? this.data.shareInfo.pid : -1,
  1241. }
  1242. }
  1243. };
  1244. e.currentTarget = data;
  1245. }
  1246. this.goPay(e)
  1247. },
  1248. chat() {
  1249. this.data.show = this.defaultShow();
  1250. this.data.show.chat = true;
  1251. this.setData({
  1252. url: '/page/baodada.html',
  1253. show: this.data.show
  1254. });
  1255. },
  1256. alternatePopup(e) {
  1257. this.setData({
  1258. showAlternatePopup: false
  1259. })
  1260. },
  1261. toTop() {
  1262. wx.pageScrollTo({
  1263. scrollTop: 0,
  1264. duration: 300
  1265. })
  1266. },
  1267. pageCount() {
  1268. let userInfo = app.globalData.userInfo,
  1269. that = this,
  1270. aid = this.data.aid,
  1271. temCountId = this.data.temCountId;
  1272. if (userInfo) {
  1273. if (temCountId) {
  1274. util.ajax({
  1275. func: "user/browhistory_out",
  1276. data: {
  1277. 'id': temCountId,
  1278. 'url': that.data.url,
  1279. 'timeOut': Date.parse(new Date()),
  1280. 'source': 'applet'
  1281. },
  1282. load: false
  1283. }, function (res) {
  1284. if (res.code == 0) that.setData({
  1285. temCountId: ''
  1286. })
  1287. })
  1288. } else {
  1289. let length = getCurrentPages().length,
  1290. dataArr = {
  1291. 'rid': userInfo.rid,
  1292. 'aid': aid,
  1293. 'url': length == 1 ? '/page/product_detail.html' : '/',
  1294. 'timeIn': Date.parse(new Date()),
  1295. 'source': 'applet'
  1296. };
  1297. util.ajax({
  1298. func: "user/browhistory_in",
  1299. data: dataArr,
  1300. load: false
  1301. },
  1302. function (res) {
  1303. if (res.code == 0) that.setData({
  1304. temCountId: res.data
  1305. })
  1306. });
  1307. }
  1308. }
  1309. },
  1310. // 出行人列表图片加载失败显示默认图片
  1311. errorPic(e) {
  1312. let index = e.currentTarget.dataset.i,
  1313. url = 'datas.users[' + index + '].avatar';
  1314. this.data.datas.users[index].avatar = '/images/default_logo.jpg';
  1315. this.setData({
  1316. datas: this.data.datas
  1317. })
  1318. },
  1319. navigatorTo(e) {
  1320. util.navigator(e.currentTarget.dataset.url);
  1321. },
  1322. invite() {
  1323. let getChannel = util.config.channelInfo;
  1324. if (getChannel.channel) {
  1325. this.setData({
  1326. channel: getChannel.channel,
  1327. channelTimes: getChannel.channelTimes
  1328. })
  1329. }
  1330. this.data.show = this.defaultShow();
  1331. this.data.show.share = true;
  1332. this.setData({
  1333. show: this.data.show
  1334. });
  1335. },
  1336. newGroup(e) {
  1337. if (this.data.showEnrollPopup) {
  1338. util.config.invitePopupTime = false;
  1339. this.setData({
  1340. showEnrollPopup: false,
  1341. inviteEnroll: true
  1342. });
  1343. }
  1344. if (e.currentTarget.dataset.creategroup) {
  1345. this.data.growupInfo.createGroup = parseInt(e.currentTarget.dataset.creategroup);
  1346. } else {
  1347. this.data.growupInfo.createGroup = parseInt(e.detail);
  1348. if (this.data.showGrouPopup) {
  1349. this.setData({
  1350. showGrouPopup: false
  1351. });
  1352. }
  1353. }
  1354. this.data.show = this.defaultShow();
  1355. this.data.show.growup = true;
  1356. this.setData({
  1357. growupInfo: this.data.growupInfo,
  1358. show: this.data.show,
  1359. isBuy: Boolean(this.data.growupInfo.createGroup)
  1360. });
  1361. },
  1362. integral() {
  1363. this.data.show = this.defaultShow();
  1364. this.data.show.integral = true;
  1365. this.setData({
  1366. show: this.data.show
  1367. });
  1368. },
  1369. previewImage(e) {
  1370. let index = e.currentTarget.dataset.index,
  1371. i = e.target.dataset.i,
  1372. comments = this.data.comments.comments;
  1373. this.setData({
  1374. onshow: false
  1375. });
  1376. wx.previewImage({
  1377. current: comments[index].imageList[i], // 当前显示图片的http链接
  1378. urls: comments[index].imageList // 需要预览的图片http链接列表
  1379. })
  1380. },
  1381. previewFimages(e) {
  1382. let index = e.currentTarget.dataset.index,
  1383. i = e.target.dataset.i,
  1384. comments = this.data.comments.comments;
  1385. this.setData({
  1386. onshow: false
  1387. });
  1388. wx.previewImage({
  1389. current: comments[index].fcomments.fimages[i], // 当前显示图片的http链接
  1390. urls: comments[index].fcomments.fimages // 需要预览的图片http链接列表
  1391. })
  1392. },
  1393. getSkuInfo() {
  1394. let that = this;
  1395. util.ajax({
  1396. func: "v2/article/payinfo",
  1397. data: {
  1398. "aid": that.data.aid
  1399. },
  1400. load: false
  1401. }, function (res) {
  1402. if (res.code == 0) {
  1403. let obj = res.data.sessions.find((el) => (el.status == 0));
  1404. that.setData({
  1405. sku: res.data,
  1406. alternateBol: (res.data.sessions && res.data.sessions.length > 0) ? (obj ? true : false) : false
  1407. });
  1408. if (util.config.invitePopupTime) {
  1409. that.findSku()
  1410. }
  1411. // if ((that.data.shareInfo.sid && that.data.shareInfo.pid && that.data.shareInfo.sharer) || that.data.shareInfo.groupid) {
  1412. // setTimeout(() => {
  1413. // that.setData({showEnrollPopup:true})
  1414. // }, 500);
  1415. // }
  1416. }
  1417. })
  1418. },
  1419. // 判断好友邀请的场次排期是否存在
  1420. findSku() {
  1421. let list = this.data.sku.sessions,
  1422. data = {},
  1423. sid = this.data.shareInfo.sid,
  1424. pid = this.data.shareInfo.pid;
  1425. for (let i = 0; i < list.length; i++) {
  1426. if (list[i].sid == sid) {
  1427. data.sessionName = list[i].name;
  1428. for (let index = 0; index < list[i].meals.length; index++) {
  1429. if (list[i].meals[index].pid == pid) {
  1430. data.mealsName = list[i].meals[index].policyName;
  1431. // return false;
  1432. }
  1433. }
  1434. }
  1435. }
  1436. setTimeout(() => {
  1437. if ((!util.isEmpty(data.mealsName) && !util.isEmpty(data.sessionName)) || !util.isEmpty(this.data.shareInfo.groupid)) {
  1438. this.setData({
  1439. showEnrollPopup: true,
  1440. 'shareInfo.sessionName': data.sessionName,
  1441. 'shareInfo.mealsName': data.mealsName
  1442. })
  1443. }
  1444. }, 500);
  1445. },
  1446. onShareAppMessage() {
  1447. var datas = this.data.datas,
  1448. that = this,
  1449. inviteCode = '',
  1450. channelInfo = util.config.channelInfo;
  1451. this.shareRecord(datas);
  1452. // 判断当前用户是机构,是使用当前用户邀请码,不是使用分享过来的
  1453. if (this.data.userInfo.roleType == 'organ') {
  1454. if (!util.isEmpty(datas.inviteCode)) {
  1455. inviteCode = datas.inviteCode;
  1456. } else {
  1457. inviteCode = app.globalData.userInfo ? app.globalData.userInfo.code : '';
  1458. }
  1459. } else {
  1460. inviteCode = this.data.shareInvite ? this.data.shareInvite : app.globalData.userInfo ? app.globalData.userInfo.code : '';
  1461. }
  1462. wx.reportAnalytics('active_share', {
  1463. aid: datas.aid,
  1464. title: datas.title,
  1465. });
  1466. return {
  1467. title: (that.data.groupid || that.data.orderid ? '约吗?快来和我家孩子一起拼团挑战' : '约吧,邀请你家宝贝一起参加活动'),
  1468. path: '/pages/product/activity/index?aid=' +
  1469. datas.aid +
  1470. ('&invite=' + inviteCode) + ((channelInfo.channel != 0 && !util.isEmpty(channelInfo.channel) && channelInfo.channelTimes == 1) ? ('&channel=' + channelInfo.channel) : '') +
  1471. ((channelInfo.channel != 0 && channelInfo.channelTimes == 1) ? ('&channelTimes=' + (parseInt(channelInfo.channelTimes) + 1)) : '')
  1472. }
  1473. },
  1474. // 分享到朋友圈 不支持自定义
  1475. onShareTimeline() {
  1476. var datas = this.data.datas,
  1477. that = this,
  1478. inviteCode = '',
  1479. channelInfo = util.config.channelInfo;
  1480. this.shareRecord(datas);
  1481. // 判断当前用户是机构,是使用当前用户邀请码,不是使用分享过来的
  1482. if (this.data.userInfo.roleType == 'organ') {
  1483. if (!util.isEmpty(datas.inviteCode)) {
  1484. inviteCode = datas.inviteCode;
  1485. } else {
  1486. inviteCode = app.globalData.userInfo ? app.globalData.userInfo.code : '';
  1487. }
  1488. } else {
  1489. inviteCode = this.data.shareInvite ? this.data.shareInvite : app.globalData.userInfo ? app.globalData.userInfo.code : '';
  1490. }
  1491. wx.reportAnalytics('active_share', {
  1492. aid: datas.aid,
  1493. title: datas.title,
  1494. });
  1495. return {
  1496. title: (that.data.groupid || that.data.orderid ? '约吗?快来和我家孩子一起拼团挑战' : '约吧,邀请你家宝贝一起参加活动'),
  1497. path: '/pages/product/activity/index?aid=' +
  1498. datas.aid +
  1499. ('&invite=' + inviteCode) + ((channelInfo.channel != 0 && !util.isEmpty(channelInfo.channel) && channelInfo.channelTimes == 1) ? ('&channel=' + channelInfo.channel) : '') +
  1500. ((channelInfo.channel != 0 && channelInfo.channelTimes == 1) ? ('&channelTimes=' + (parseInt(channelInfo.channelTimes) + 1)) : '')
  1501. }
  1502. },
  1503. // 记录分享次数
  1504. shareRecord(data) {
  1505. if (!util.isEmpty(data.aid)) {
  1506. util.ajax({
  1507. func: 'article/share',
  1508. data: {
  1509. "aid": data.aid
  1510. },
  1511. load: false
  1512. }, function (res) {
  1513. if (res.code == 0) {
  1514. console.log(res.reason)
  1515. }
  1516. })
  1517. }
  1518. },
  1519. // 自动播放
  1520. previewVideo(e) {
  1521. console.log(e);
  1522. wx.previewMedia({
  1523. sources: [{
  1524. url: e.currentTarget.dataset.vdurl, //视频播放路径
  1525. type: 'video' //video视频 image图片
  1526. }]
  1527. })
  1528. },
  1529. //视频号
  1530. channelVideo(e) {
  1531. let feedId = e.currentTarget.dataset.vdnum
  1532. let finderUserName = e.currentTarget.dataset.uname
  1533. wx.openChannelsActivity({
  1534. finderUserName,
  1535. feedId,
  1536. success: function (res) {
  1537. console.log(res)
  1538. },
  1539. complete: function () {
  1540. console.log('调用');
  1541. }
  1542. })
  1543. },
  1544. // 图片预览
  1545. actPreviewImage(e) {
  1546. console.log(e);
  1547. let index = e.currentTarget.dataset.index
  1548. let urls = []
  1549. let actDetail = this.data.marvellousList
  1550. actDetail.forEach((e) => {
  1551. if (e.type == 4) {
  1552. urls.push(e.logo)
  1553. }
  1554. })
  1555. let imgUrl = e.currentTarget.dataset.imgurl
  1556. // urls.push(imgUrl)
  1557. wx.previewImage({
  1558. current: e.currentTarget.dataset.imgurl, // 当前显示图片的http链接
  1559. urls,
  1560. })
  1561. }
  1562. })