// pages/product/product.js' import { request } from "../../utils/bin" var WxParse = require('../../utils/wxParse/wxParse'); Page({ /** * 页面的初始数据 */ data: { array: ['20粒', '30粒', '50粒', '100粒'], userid: 0, specs: [{ 'item': '默认规格' }], article:"" }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { console.log(options) request({ url: "Goods/goodsInfo", data: { id: options.shopid } }).then((res) => { // console.log(res) this.setData({ info: res.data.result, shopid: options.shopid, }) var that = this; WxParse.wxParse('article', 'html', that.data.info.goods.goods_content, that, 5); // console.log(this.data.type, 150) }) request({ url: "User/validateOpenid" }).then((res) => { console.log(res) this.setData({ userid: res.data.data.user_id }) }) }, // goshop() { // }, bindPickerChange(e) { console.log(e.detail.value) request({ url: "Cart/addCart", data: { goods_id: this.data.shopid, goods_num: 1, goods_spec: this.data.info.goods.goods_spec_list ? this.data.info.goods.goods_spec_list[0][e.detail.value].item_id : '', user_id: this.data.userid }, name: "session_id" }).then((res) => { console.log(res) wx.switchTab({ url: '/pages/shopping/shopping' }) }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })