123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- // pages/details/details.js
- const getReq = require('./../../config.js').getReq
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- imgUrls: [],
- datas: {},
- getOneSummary: [],
- webViewUrl: '',
- indicatorDots: true,
- vertical: false,
- autoplay: true,
- interval: 2000,
- duration: 500,
- animation_flag: false,
- sec_index: 0
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- let webViewUrl = `https://passport.lrlz.com/mobile/index.php?act=goods_common&op=detail&goods_id=${options.goods_id}&client_type=ios`
- this.setData({
- webViewUrl
- })
- this.getDatas(options.goods_id)
- // this.getDatas(6417)
- },
- getDatas(goods_id) {
- var self = this
- getReq({
- act: 'goods_common',
- op: 'index',
- goods_id
- }, function (res) {
- if (res.code == 200) {
- let oneSummary = self.getOneSummary(res.datas.summary,goods_id)
- console.log('---')
- console.log(oneSummary)
- self.setData({
- datas: res.datas,
- getOneSummary: oneSummary,
- imgUrls: res.datas.common_info.images
- })
-
- }
- })
- },
- getOneSummary(sumarys,goods_id) {
- let getOneSummary = sumarys.filter((item, index) => {
- return item.goods_id == goods_id
- })
- return getOneSummary[0]
- },
- secSku(e) {
- let skus = e.currentTarget.dataset.skus
- let goodsId = e.currentTarget.dataset.goodsid
- let sec_index = e.currentTarget.dataset.secindex
- let getOneSummary = this.getOneSummary(this.data.datas.summary, goodsId)
- this.setData({
- sec_index,
- getOneSummary
- })
- },
- toWebView() {
- let webViewUrl = encodeURIComponent(this.data.webViewUrl)
- wx.navigateTo({
- url: `/pages/webView/webView?url=${webViewUrl}`
- })
- },
- animation_flag(e) {
- let flag = e.currentTarget.dataset.flag
- let animation_flag = flag == 'true' ? true : false
- this.setData({
- animation_flag
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|