1
0

index.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  1. const util = require('../../utils/util.js');
  2. const api = require('../../config/api.js');
  3. const user = require('../../services/user.js');
  4. //获取应用实例
  5. const app = getApp();
  6. Page({
  7. data: {
  8. groupGoods: [],
  9. hotGoods: [],
  10. topics: [],
  11. brands: [],
  12. floorGoods: [],
  13. banner: [],
  14. channel: [],
  15. groupBanner: {},
  16. storeName: '',
  17. showPop: false, //活动弹窗
  18. couponVo: {},
  19. storeId: '',
  20. page: 1,
  21. size: 3,
  22. list: [],
  23. openAttr: false,
  24. isMapShow: '', //第三方商户是否启用地图显示
  25. isStartLocation: null,
  26. isSystemLocation: null
  27. },
  28. onLoad: function(options) {
  29. let that = this;
  30. wx.setStorageSync("navUrl", "/pages/index/index");
  31. // options.scene = 148;
  32. // options.scene = 93;
  33. // options.scene = 38;
  34. // options.scene = 67;
  35. // options.scene = 28;
  36. // options.scene = 8;
  37. if (options.scene) {
  38. // console.log("have scene");
  39. var scene = decodeURIComponent(options.scene);
  40. console.log("scene is ", scene);
  41. that.setData({
  42. storeId: scene
  43. });
  44. wx.setStorageSync('storeId', scene);
  45. //扫码进入的小程序则清除是否分享缓存
  46. wx.removeStorageSync('isShare');
  47. } else {
  48. //是否分享过商品,有数据则分享过;从首页进入页面则没有分享过,从详情页进入则分享过
  49. if (wx.getStorageSync('isShare') == 'true') {
  50. console.log('是分享进入首页门店id:' + wx.getStorageSync('storeId') + ',从商品页获取的缓存')
  51. console.log('是分享进入首页:' + wx.getStorageSync('isShare'))
  52. } else {
  53. //小程序入口进入的主页,则清除storeId,获取当前地址最近的门店
  54. wx.removeStorageSync('storeId');
  55. // console.log('不是分享进入首页门店id:【' + wx.getStorageSync('storeId') + '】,获取最近门店')
  56. // console.log('不是分享进入首页:' + wx.getStorageSync('isShare'))
  57. }
  58. }
  59. wx.getLocation({
  60. success: function(location) {
  61. that.successLoadStore(location);
  62. },
  63. fail: function() {
  64. wx.hideLoading();
  65. wx.getSetting({
  66. success: function(res) {
  67. if (!res.authSetting['scope.userLocation']) {
  68. wx.showModal({
  69. title: '',
  70. content: '检测到您没有开启获取地理位置权限,是否开启',
  71. confirmText: '确定',
  72. success: function(resConfirm) {
  73. if (resConfirm.confirm) {
  74. wx.openSetting();
  75. } else {
  76. that.setData({
  77. isStartLocation: false
  78. });
  79. }
  80. }
  81. })
  82. } else {
  83. //用户已授权,但是获取地理位置失败,提示用户去系统设置中打开定位
  84. wx.showModal({
  85. title: '',
  86. content: '请在系统设置中打开定位服务',
  87. confirmText: '确定',
  88. showCancel: false,
  89. success: function(resConfirm2) {
  90. that.setData({
  91. isSystemLocation: false
  92. });
  93. }
  94. })
  95. }
  96. }
  97. })
  98. }
  99. });
  100. },
  101. onReady: function() {
  102. // 页面渲染完成
  103. },
  104. onShow: function() {
  105. // 页面显示
  106. let that = this;
  107. wx.setStorageSync("navUrl", "/pages/index/index");
  108. wx.setStorageSync("isLocationIndex", "false"); //购物车是否已跳转登录页,到首页重置字段为false未跳转
  109. if (!wx.getStorageSync('isRefusedLogin')) {
  110. wx.setStorageSync('isRefusedLogin', 'true'); //拒绝授权
  111. }
  112. that.syncStore();
  113. // if (wx.getStorageSync('userInfo') && wx.getStorageSync('token')) {
  114. // } else {
  115. // // console.log('拒绝授权:' + wx.getStorageSync('isRefusedLogin'))
  116. // if (wx.getStorageSync('isRefusedLogin') != 'true') {
  117. // wx.navigateTo({
  118. // url: '/pages/auth/btnAuth/btnAuth',
  119. // })
  120. // }
  121. // }
  122. },
  123. onHide: function() {
  124. // 页面隐藏
  125. },
  126. onUnload: function() {
  127. // 页面关闭
  128. },
  129. showCouponPop() {
  130. let that = this;
  131. this.setData({
  132. showPop: false
  133. });
  134. // wx.showToast({
  135. // title: '恭喜获取优惠券一张' + that.data.couponVo.name,
  136. // duration: 2000
  137. // });
  138. wx.showModal({
  139. title: '获取优惠券一张',
  140. showCancel: false,
  141. content: that.data.couponVo.name
  142. })
  143. },
  144. onShareAppMessage: function() {
  145. var that = this;
  146. // console.log('分享:' + that.data.storeId)
  147. return {
  148. title: '中网跨境电商主页',
  149. desc: '中网跨境电商主页',
  150. path: '/pages/index/index?scene=' + that.data.storeId
  151. }
  152. },
  153. // 同步门店
  154. syncStore: function() {
  155. let that = this;
  156. // console.log(wx.getStorageSync('merchSn'));
  157. //获取附件门店信息
  158. // util.getLocation((lng, lat) => {
  159. wx.getLocation({
  160. success: function(location) {
  161. // console.log(location)
  162. that.successLoadStore(location);
  163. },
  164. fail: function() {
  165. wx.hideLoading();
  166. wx.getSetting({
  167. success: function(res) {
  168. if (!res.authSetting['scope.userLocation']) {
  169. that.setData({
  170. isStartLocation: false
  171. });
  172. } else {
  173. //用户已授权,但是获取地理位置失败,提示用户去系统设置中打开定位
  174. that.setData({
  175. isSystemLocation: false
  176. });
  177. // wx.showModal({
  178. // title: '',
  179. // content: '请在系统设置中打开定位服务',
  180. // confirmText: '确定',
  181. // showCancel: false,
  182. // success: function (resConfirm2) {
  183. // that.setData({
  184. // isSystemLocation: false
  185. // });
  186. // }
  187. // })
  188. }
  189. }
  190. });
  191. }
  192. });
  193. },
  194. /**
  195. * 打开微信定位
  196. */
  197. openSetLocation: function() {
  198. wx.openSetting();
  199. },
  200. /**confirmLocation: function () {
  201. let that = this;
  202. wx.showModal({
  203. title: '',
  204. content: '检测到您没有开启获取地理位置权限,是否开启',
  205. confirmText: '确定',
  206. success: function (resConfirm) {
  207. if (resConfirm.confirm) {
  208. wx.openSetting();
  209. } else {
  210. that.confirmLocation();
  211. }
  212. }
  213. })
  214. },**/
  215. /**
  216. * 定位确定授权加载附近门店信息
  217. */
  218. successLoadStore: function(location) {
  219. let that = this;
  220. that.setData({
  221. isStartLocation: true,
  222. isSystemLocation: true
  223. });
  224. var lng = location.longitude;
  225. var lat = location.latitude;
  226. wx.setStorageSync('location', JSON.stringify({
  227. lng,
  228. lat
  229. }));
  230. let storeId = wx.getStorageSync('storeId');
  231. util.request(api.NearbyList, {
  232. longitude: lng,
  233. latitude: lat,
  234. storeId: storeId,
  235. thirdPartyMerchCode: ''
  236. }).then((res) => {
  237. let nlist = res.data;
  238. // wx.removeStorageSync('nearStoreList');
  239. // wx.removeStorageSync('storeId');
  240. // wx.removeStorageSync('storeVo');
  241. // wx.setStorageSync('storeId', storeId);
  242. if (!wx.getStorageSync('currentCategory')) {
  243. wx.removeStorageSync('currentCategory');
  244. }
  245. if (!nlist.length) {
  246. wx.removeStorageSync('nearStoreList');
  247. wx.removeStorageSync('mapIndexStoreId');
  248. } else {
  249. wx.setStorageSync('nearStoreList', JSON.stringify(nlist));
  250. wx.setStorageSync('mapIndexStoreId', nlist[0].id);
  251. }
  252. if (!nlist.length) {
  253. // wx.removeStorageSync('storeId');
  254. wx.removeStorageSync('storeVo');
  255. that.setData({
  256. storeName: '附近暂无门店'
  257. })
  258. } else {
  259. that.setData({
  260. storeName: nlist[0].storeName,
  261. storeId: nlist[0].id
  262. })
  263. that.chooseStore(nlist[0].id, nlist[0].merchSn);
  264. wx.setStorageSync('storeVo', JSON.stringify(nlist[0]));
  265. }
  266. })
  267. },
  268. // 更新门店Id
  269. chooseStore: function(storeId, merchSn) {
  270. let that = this;
  271. util.request(api.ChooseStoreId, {
  272. storeId: storeId,
  273. merchSn: merchSn,
  274. isRefusedLogin: wx.getStorageSync('isRefusedLogin')
  275. }, 'POST').then(function(res) {
  276. if (res.errno === 0) {
  277. wx.setStorageSync('storeId', storeId);
  278. wx.setStorageSync('merchSn', merchSn);
  279. wx.setStorageSync('token', res.data.token);
  280. if (wx.getStorageSync('userInfo') && wx.getStorageSync('token')) {
  281. that.reLoad();
  282. } else {
  283. wx.setStorageSync('isLoadGoods', '0'); //1:代表每次点首页都会重新加载商品,0:否
  284. }
  285. that.getIndexData();
  286. that.enableActivity();
  287. that.getGroupData();
  288. }
  289. });
  290. },
  291. reLoad: function() {
  292. let that = this;
  293. // console.log(wx.getStorageSync('userId'));
  294. // console.log(wx.getStorageSync('storeId'));
  295. // console.log(wx.getStorageSync('merchSn'));
  296. if (wx.getStorageSync('storeId')) {
  297. if (wx.getStorageSync('userId')) {
  298. wx.request({
  299. url: api.updateLoginUser,
  300. data: {
  301. userId: wx.getStorageSync('userId'),
  302. storeId: wx.getStorageSync('storeId'),
  303. merchSn: wx.getStorageSync('merchSn')
  304. },
  305. method: 'POST',
  306. header: {
  307. 'Content-Type': 'application/json'
  308. },
  309. success: function(wxRes) {
  310. if (wxRes.data.errno === 0) {
  311. that.setData({
  312. isMapShow: wxRes.data.data.isMapShow
  313. });
  314. // console.log(wxRes.data.data.isLoadGoods);
  315. wx.setStorageSync('isLoadGoods', wxRes.data.data.isLoadGoods);
  316. wx.setStorageSync('thirdPartyMerchCode', wxRes.data.data.thirdPartyMerchCode);
  317. // console.log(that.data.isMapShow)
  318. // console.log("用户信息更新成功");
  319. }
  320. },
  321. fail: function(err) {
  322. console.log("failed");
  323. }
  324. });
  325. }
  326. }
  327. },
  328. getIndexData: function() {
  329. setTimeout(function() {}, 350)
  330. wx.showLoading({
  331. title: '加载中...',
  332. })
  333. let that = this;
  334. util.request(api.IndexUrl).then(function(res) {
  335. if (res.errno === 0) {
  336. // console.log(res.data.banner);
  337. that.setData({
  338. // newGoods: res.data.newGoodsList,
  339. // hotGoods: res.data.hotGoodsList,
  340. // topics: res.data.topicList,
  341. // brand: res.data.brandList,
  342. // floorGoods: res.data.categoryList,
  343. banner: res.data.banner,
  344. // groupBanner: res.data.groupBanner,
  345. channel: res.data.channel
  346. });
  347. // console.log(that.data.hotGoods.length)
  348. // console.log(wx.getStorageSync('storeId'))
  349. // console.log(wx.getStorageSync('mapIndexStoreId'))
  350. // if (that.data.hotGoods.length == 0) {
  351. // that.getGoodsList();
  352. // }
  353. // console.log("mapIndexStoreId:" + wx.getStorageSync('mapIndexStoreId'))
  354. // console.log("storeId:" + wx.getStorageSync('storeId'))
  355. // console.log("isShare:" + wx.getStorageSync('isShare'))
  356. // console.log("isLoadGoods:" + wx.getStorageSync('isLoadGoods'))
  357. //当切换了门店地图(mapIndexStoreId),或是由用户分享进入的商品详情切换进入的首页(isShare:true)
  358. if (wx.getStorageSync('storeId') != wx.getStorageSync('mapIndexStoreId') || wx.getStorageSync('isShare') == 'true' || that.data.hotGoods.length == 0 || wx.getStorageSync('isLoadGoods') == '1') {
  359. that.setData({
  360. hotGoods: [],
  361. page: 1
  362. });
  363. that.getGoodsList();
  364. if (wx.getStorageSync('isLoadGoods') == '1') {
  365. util.request(api.UpdateStoreLoadGoods, {
  366. storeId: wx.getStorageSync('storeId')
  367. }).then(function(res) {});
  368. }
  369. wx.setStorageSync('isShare', 'false');
  370. }
  371. }
  372. wx.hideLoading();
  373. });
  374. },
  375. getGoodsList: function() {
  376. let that = this;
  377. util.request(api.GoodsHot).then(function(res) {
  378. if (res.errno == 0) {
  379. util.request(api.HotGoodsList, {
  380. isHot: 1,
  381. page: that.data.page,
  382. size: that.data.size,
  383. categoryId: 0
  384. })
  385. .then(function(res) {
  386. if (res.errno == 0) {
  387. let goodsList = that.data.hotGoods.concat(res.data.goodsList);
  388. that.setData({
  389. hotGoods: goodsList,
  390. list: res.data.goodsList
  391. });
  392. }
  393. });
  394. wx.hideLoading();
  395. }
  396. });
  397. },
  398. getGroupData: function() {
  399. let that = this;
  400. util.request(api.GroupList).then(function(res) {
  401. if (res.errno === 0) {
  402. that.setData({
  403. groupGoods: res.data.data,
  404. });
  405. }
  406. });
  407. },
  408. handleStore() {
  409. wx.navigateTo({
  410. url: '../map/map',
  411. })
  412. },
  413. goSearch() {
  414. wx.navigateTo({
  415. url: '../search/search',
  416. })
  417. },
  418. goCatalog: function(e) {
  419. let url = '';
  420. // console.log('dataset.goodsBizType:' + e.currentTarget.dataset.goodsBizType);
  421. app.globalData.appGoodsBizType = e.currentTarget.dataset.goodsBizType;
  422. // console.log('appgoodsBizType1:' + app.globalData.appGoodsBizType);
  423. wx.setStorageSync('isSwitchCatalog', 'true'); //主页跳转至分类页加载商品,
  424. wx.switchTab({
  425. url: '/pages/catalog/catalog',
  426. });
  427. },
  428. onReachBottom: function() {
  429. if (this.data.bottomLoadDone === true || this.data.bottomLoading === true) {
  430. return false;
  431. }
  432. this.setData({
  433. bottomLoading: true
  434. });
  435. // this.getFloorCategory();
  436. },
  437. //购物车减少
  438. cutNumber: function(e) {
  439. let that = this;
  440. var goodsId = e.currentTarget.dataset.goodsId;
  441. var productId = e.currentTarget.dataset.productId;
  442. var hotGoods = that.data.hotGoods;
  443. // hotGoods.forEach(function (val, index, arr) {
  444. // if (val.product_id == productId) {
  445. // val.cart_num = val.cart_num - 1;
  446. // if (val.cart_num >= 0) {
  447. // hotGoods[index] = val;
  448. // }
  449. // }
  450. // });
  451. // that.setData({ hotGoods: hotGoods });
  452. util.request(api.CartMinus, {
  453. goodsId: goodsId,
  454. productId: productId,
  455. number: 1
  456. }, 'POST').then(function(res) {
  457. if (res.errno === 0 && null != res.data) {
  458. var hotGoods = that.data.hotGoods;
  459. hotGoods.forEach(function(val, index, arr) {
  460. if (val.product_id == productId) {
  461. val.cart_num = res.data;
  462. hotGoods[index] = val;
  463. that.setData({
  464. hotGoods: hotGoods
  465. });
  466. }
  467. }, that);
  468. }
  469. });
  470. },
  471. //购物车增加
  472. addNumber: function(e) {
  473. let that = this;
  474. var goodsId = e.currentTarget.dataset.goodsId;
  475. var productId = e.currentTarget.dataset.productId;
  476. var hotGoods = that.data.hotGoods;
  477. // hotGoods.forEach(function (val, index, arr) {
  478. // if (val.product_id == productId) {
  479. // val.cart_num = val.cart_num + 1;
  480. // hotGoods[index] = val;
  481. // }
  482. // });
  483. // that.setData({ hotGoods: hotGoods });
  484. util.request(api.CartAdd, {
  485. goodsId: goodsId,
  486. productId: productId,
  487. number: 1
  488. }, 'POST').then(function(res) {
  489. if (res.errno === 0 && null != res.data) {
  490. hotGoods.forEach(function(val, index, arr) {
  491. res.data.cartList.forEach(function(cartVal, cartIndex, cartArr) {
  492. if (val.product_id == cartVal.product_id) {
  493. val.cart_num = cartVal.number;
  494. hotGoods[index] = val;
  495. }
  496. });
  497. that.setData({
  498. hotGoods: hotGoods
  499. });
  500. }, that);
  501. wx.showToast({
  502. title: '添加成功'
  503. })
  504. } else {
  505. wx.showToast({
  506. title: res.errmsg,
  507. icon: 'none'
  508. })
  509. }
  510. });
  511. },
  512. // 查询是否有活动
  513. enableActivity: function() {
  514. let that = this;
  515. let couponIds = wx.getStorageSync('couponIds');
  516. if (!couponIds) {
  517. couponIds = new Array();
  518. }
  519. // util.request(api.EnableActivity, { couponIds: couponIds }).then(function (res) {
  520. // // if (res.errno === 0 && null != res.data.showCoupon) {
  521. // // if (couponIds.contains(res.data.showCoupon.id)) {
  522. // // return;
  523. // // }
  524. // // couponIds.push(res.data.showCoupon.id);
  525. // // wx.setStorageSync('couponIds', couponIds);
  526. // // that.setData({
  527. // // couponVo: res.data.showCoupon,
  528. // // showPop: true
  529. // // });
  530. // // } else
  531. // if (res.errno === 0 && null != res.data.takeCoupon && null != res.data.takeCoupon.id) {
  532. // that.setData({
  533. // couponVo: res.data.takeCoupon,
  534. // showPop: true
  535. // });
  536. // }
  537. // });
  538. },
  539. // 商品扫码
  540. scanGoodsCode: function(e) {
  541. var that = this;
  542. var code;
  543. var value;
  544. var substrValue;
  545. var scanType;
  546. // 调起客户端扫码界面进行扫码
  547. wx.scanCode({
  548. // 是否只能从相机扫码
  549. onlyFromCamera: true,
  550. // 扫码类型, barCode:一维码, qrCode:二维码
  551. scanType: ['barCode', 'qrCode'],
  552. success: function(res) {
  553. that.code = "结果:" + res.result + ",路径:" + res.path + ",编码:" + res.rawData;
  554. that.value = res.result;
  555. that.scanType = res.scanType;
  556. that.setData({
  557. goodsCode: that.code
  558. });
  559. if (that.scanType == 'QR_CODE') { //二维码
  560. that.substrValue = that.value.substring(0, 5);
  561. that.value = that.value.substring(5, that.value.length);
  562. // var goodId = that.value.substring(18, that.value.length);
  563. var scanArray = that.value.split('&');
  564. // console.log(scanArray.length);
  565. if (scanArray.length < 2) {
  566. wx.showModal({
  567. title: '',
  568. content: '您所扫描的商品无效',
  569. showCancel: false
  570. });
  571. return;
  572. }
  573. var goodId = scanArray[0].substring(18, that.value.length);
  574. var storeId = scanArray[1].substring(8, that.value.length);
  575. // console.log("storeId:" + storeId);
  576. // console.log("goodId:" + goodId);
  577. if (that.substrValue != 'emato') { //../goods/goods?id=&merchSn=
  578. wx.showModal({
  579. title: '',
  580. content: '您所扫描的商品无效',
  581. showCancel: false,
  582. success: function(res) {
  583. if (res.confirm) {
  584. console.log('用户点击确定')
  585. } else if (res.cancel) {
  586. console.log('用户点击取消')
  587. }
  588. }
  589. });
  590. return;
  591. }
  592. if (storeId != wx.getStorageSync('storeId')) {
  593. wx.showModal({
  594. title: '扫描结果',
  595. content: '该商品不属于当前门店',
  596. showCancel: false
  597. });
  598. return;
  599. }
  600. util.request(api.GoodsDetail, {
  601. id: goodId,
  602. storeId: storeId,
  603. referrer: ''
  604. }).then(function(res) {
  605. if (res.errno === 0) {
  606. // console.log(res);
  607. // 跳转页面
  608. setTimeout(function() {
  609. wx.navigateTo({
  610. url: that.value,
  611. success: function(e) {
  612. console.log('跳转成功');
  613. },
  614. fail: function(e) {
  615. console.log('跳转失败');
  616. }
  617. })
  618. }, 350)
  619. } else {
  620. wx.showModal({
  621. title: '扫描结果',
  622. content: '商品不存在',
  623. showCancel: false
  624. });
  625. }
  626. });
  627. } else { //其他码
  628. //弹框显示结果
  629. wx.showModal({
  630. title: '扫描结果',
  631. content: that.value,
  632. showCancel: false
  633. });
  634. }
  635. },
  636. fail: function() {
  637. // 显示提示框
  638. wx.showToast({
  639. title: '扫码失败',
  640. icon: 'none',
  641. // 提示的延迟时间
  642. duration: 3000
  643. })
  644. }
  645. })
  646. },
  647. imgOnLoad: function(e) {
  648. let that = this;
  649. // console.log('图片加载完成');
  650. // var realthumb = e.target.dataset.thumb;
  651. // let list = that.data.list
  652. // for (var i = 0; i < list.length; i++) {
  653. // if (list[i].thumb == realthumb) {
  654. // list[i].loaded = true
  655. // }
  656. // that.setData({
  657. // list: list
  658. // })
  659. // }
  660. },
  661. switchAttrPop: function() {
  662. this.setData({
  663. openAttr: !this.data.openAttr
  664. })
  665. },
  666. hideSwitchAttrPop: function() {
  667. this.setData({
  668. openAttr: false
  669. })
  670. },
  671. //购物车增加
  672. addCart: function(e) {
  673. let that = this;
  674. that.setData({
  675. number: 1
  676. });
  677. var goodsId = e.currentTarget.dataset.goodsId;
  678. var retailPrice = e.currentTarget.dataset.retailPrice;
  679. util.request(api.GoodsSku, {
  680. goodsId: goodsId
  681. }).then(function(res) {
  682. if (res.errno === 0 && null != res.data) {
  683. that.setData({
  684. goodsVo: res.data.goodsVo,
  685. specificationList: res.data.specificationList,
  686. productList: res.data.productList,
  687. openAttr: !that.data.openAttr,
  688. retailPrice: retailPrice,
  689. stockNum: res.data.stockNum,
  690. cartNumber: res.data.cartNumber,
  691. checkedSpecText: res.data.specificationList[0].valueList[0].value
  692. });
  693. //
  694. let _specificationList = res.data.specificationList;
  695. for (let i = 0; i < _specificationList.length; i++) {
  696. if (_specificationList[i].valueList.length == 1) {
  697. //如果已经选中,则反选
  698. _specificationList[i].valueList[0].checked = true;
  699. }
  700. }
  701. that.setData({
  702. 'specificationList': _specificationList
  703. });
  704. }
  705. });
  706. },
  707. shows: function(e) {
  708. // wx.redirectTo({
  709. // url: '/pages/images/images'
  710. // })
  711. wx.navigateTo({
  712. url: '../ucenter/campMinus/campMinus?campMinusId=' + 9 + '&&storeId=' + 8 + '&&campName=' + '满200减50' + "&&isShare=1"
  713. })
  714. },
  715. onReachBottom() {
  716. var that = this;
  717. if (that.data.list.length > 0) {
  718. // console.log(that.data.list)
  719. wx.showLoading({
  720. title: '加载中...',
  721. })
  722. }
  723. that.setData({
  724. page: that.data.page + 1
  725. });
  726. that.getGoodsList();
  727. }
  728. })