You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
209 lines
5.1 KiB
209 lines
5.1 KiB
// pages/constitutionAnalyse/constitutionAnalyse.js
|
|
var WxParse = require('../../wxParse/wxParse.js');
|
|
var app = getApp();
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
catelist:[],//
|
|
user_id:0,
|
|
detail:[],
|
|
cid:[],
|
|
setcolor:['pinghezhi','qixuzhi','shirezhi','yinxuzhi','qiyuzhi','yangxuzhi','tanshizhi','xueyuzhi','tezhi'],
|
|
minipic:'',
|
|
picList:[
|
|
|
|
]
|
|
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.getUserId();
|
|
if(options.testcate_id){
|
|
let ids = JSON.parse(options.testcate_id)
|
|
this.setData({
|
|
cid:ids,
|
|
minipic:app.globalData.apiCommonUrl+'/assets/minipic/Background.png',
|
|
})
|
|
}else{
|
|
this.setData({
|
|
minipic:app.globalData.apiCommonUrl+'/assets/minipic/Background.png',
|
|
})
|
|
}
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
this.getinfo();
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
//详情
|
|
getinfo:function(cid){
|
|
var that=this;
|
|
this.setData({ loading: true });
|
|
app.request('/api/mini/solutions', {
|
|
cid:this.data.cid,
|
|
user_id:this.data.user_id,
|
|
type:1,
|
|
}, function (data, ret) {
|
|
if(ret.code == 1){
|
|
if(that.data.cid.length==0){
|
|
that.setData({
|
|
loading: false,
|
|
catelist:ret.data.lists,
|
|
detail:ret.data.detail
|
|
});
|
|
}else{
|
|
let arr = ret.data.lists;
|
|
let selectedItem = arr.filter(item=>{
|
|
return that.data.cid.includes(item.id)==true
|
|
})
|
|
that.setData({
|
|
loading: false,
|
|
catelist:selectedItem
|
|
})
|
|
|
|
}
|
|
|
|
let piclist = []
|
|
that.data.catelist.forEach(item=>{
|
|
let obj = {
|
|
title:'',
|
|
kindnum:null,
|
|
advice_content:"",
|
|
pic:'',
|
|
mini_shop_url:''
|
|
}
|
|
obj.title=item.title;
|
|
obj.kindnum=item.kindnum;
|
|
obj.advice_content = item.advice_content;
|
|
obj.pic = `../img/anew${item.kindnum}.jpg`
|
|
obj.mini_shop_url = item.mini_shop_url,
|
|
obj.titletext=item.kindnum+'号'+item.title.substr(0,2)+'饮'
|
|
piclist.push(obj)
|
|
})
|
|
that.setData({picList:piclist})
|
|
// WxParse.wxParse('advice_content', 'html',item.advice_content, that, 5);
|
|
// WxParse.wxParse('causes_content', 'html', item.causes_content, that, 5);
|
|
// WxParse.wxParse('environment_content', 'html', item.environment_content, that, 5);
|
|
// WxParse.wxParse('expression_content', 'html', item.expression_content, that, 5);
|
|
// WxParse.wxParse('features_content', 'html', item.features_content, that, 5);
|
|
// WxParse.wxParse('psychology_content', 'html', item.psychology_content, that, 5);
|
|
// WxParse.wxParse('item.tend_content', 'html', item.tend_content, that, 5);
|
|
}
|
|
typeof cb == 'function' && cb(data);
|
|
}, function (data, ret) {
|
|
|
|
that.setData({
|
|
loading: false
|
|
});
|
|
app.error(ret.msg);
|
|
},2);
|
|
},
|
|
|
|
getUserId(){
|
|
var getuser = wx.getStorageSync("userInfo");
|
|
if(getuser){
|
|
this.data.user_id = getuser.id;
|
|
}else if(wx.getStorageSync("userInfo")){
|
|
this.data.user_id = wx.getStorageSync("userInfo").id;
|
|
}else{
|
|
wx.navigateTo({
|
|
url: '/page/login/login',
|
|
});
|
|
}
|
|
},
|
|
//转发
|
|
onShareAppMessage: function() {
|
|
return {
|
|
// title: '转发',
|
|
// path: '/pages/getscore/getscore',
|
|
success: function(res) {
|
|
wx.showToast({
|
|
title: '分享成功',
|
|
icon: 'none',
|
|
duration: 1500//持续的时间
|
|
})
|
|
}
|
|
}
|
|
},
|
|
|
|
changeCid(e){
|
|
var cid = e.currentTarget.dataset.cid;
|
|
this.data.cid = cid;
|
|
this.getinfo();
|
|
},
|
|
//打开另外的小程序
|
|
goOther(e){
|
|
console.log(e.currentTarget.dataset.path)
|
|
wx.navigateToMiniProgram({
|
|
appId: 'wxb1640083b8804601',
|
|
// path: this.data.detail.mini_shop_url,
|
|
path:e.currentTarget.dataset.path,
|
|
extraData: {
|
|
foo: 'bar'
|
|
},
|
|
envVersion: 'release',
|
|
success(res) {
|
|
// 打开成功
|
|
}
|
|
})
|
|
},
|
|
goOther1(){
|
|
wx.navigateToMiniProgram({
|
|
appId: 'wxb1640083b8804601',
|
|
path: this.data.detail.mini_shop_url,
|
|
extraData: {
|
|
foo: 'bar'
|
|
},
|
|
envVersion: 'release',
|
|
success(res) {
|
|
// 打开成功
|
|
}
|
|
})
|
|
}
|
|
}) |