|
@@ -1,6 +1,6 @@
|
|
// pages/hobbyPicking/hobbyPicking.js
|
|
// pages/hobbyPicking/hobbyPicking.js
|
|
-const { getCategoryAPI } = require('../../API/appraise')
|
|
|
|
-
|
|
|
|
|
|
+const { getCategoryAPI,initRecommend } = require('../../API/appraise')
|
|
|
|
+var clientWidth = wx.getSystemInfoSync().windowWidth;
|
|
|
|
|
|
Page({
|
|
Page({
|
|
|
|
|
|
@@ -8,7 +8,8 @@ Page({
|
|
* 页面的初始数据
|
|
* 页面的初始数据
|
|
*/
|
|
*/
|
|
data: {
|
|
data: {
|
|
- classifyList: []
|
|
|
|
|
|
+ classifyList: [],
|
|
|
|
+ left:clientWidth/2-40+'px'
|
|
},
|
|
},
|
|
|
|
|
|
//获取点击分类的id
|
|
//获取点击分类的id
|
|
@@ -23,16 +24,21 @@ Page({
|
|
* 生命周期函数--监听页面加载
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
*/
|
|
onLoad(options) {
|
|
onLoad(options) {
|
|
- this.getClassifyList()
|
|
|
|
|
|
+ this.getClassifyList();
|
|
},
|
|
},
|
|
|
|
|
|
getClassifyList() {
|
|
getClassifyList() {
|
|
getCategoryAPI(this.data)
|
|
getCategoryAPI(this.data)
|
|
.then((res) => {
|
|
.then((res) => {
|
|
- const { code, data, mesage } = res.data;
|
|
|
|
|
|
+ const { code, data, mesage } = res.data;
|
|
|
|
+ data.map((item)=>{
|
|
|
|
+ console.log(item);
|
|
|
|
+ item['checked'] = false;
|
|
|
|
+ })
|
|
this.setData({
|
|
this.setData({
|
|
classifyList: data
|
|
classifyList: data
|
|
- })
|
|
|
|
|
|
+ })
|
|
|
|
+
|
|
})
|
|
})
|
|
},
|
|
},
|
|
/**
|
|
/**
|
|
@@ -82,5 +88,43 @@ Page({
|
|
*/
|
|
*/
|
|
onShareAppMessage() {
|
|
onShareAppMessage() {
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ onHobbyChange:function(e) {
|
|
|
|
+ let $id = e.currentTarget.dataset.id;
|
|
|
|
+ let _this = this.data;
|
|
|
|
+ _this.classifyList.map((item) => {
|
|
|
|
+ if(item.Id === $id)
|
|
|
|
+ {
|
|
|
|
+ item.checked = e.detail;
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ this.setData({
|
|
|
|
+ classifyList:_this.classifyList
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ initRecommendTap:function(e) {
|
|
|
|
+ let _this = this.data;
|
|
|
|
+ let cIds = [];//分类Id(用户选择)
|
|
|
|
+ for(let i of _this.classifyList)
|
|
|
|
+ {
|
|
|
|
+ if(i.checked === true)
|
|
|
|
+ {
|
|
|
|
+ cIds.push(i.Id);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ let initRecommendOption = {
|
|
|
|
+ cIds:cIds,
|
|
|
|
+ uid:wx.getStorageSync('uid')
|
|
|
|
+ }
|
|
|
|
+ initRecommend(initRecommendOption).then((res) => {
|
|
|
|
+ console.log(res);
|
|
|
|
+ wx.switchTab({
|
|
|
|
+ url: '/pages/home/home',
|
|
|
|
+ })
|
|
|
|
+ }).catch((err) => {
|
|
|
|
+ console.log(err);
|
|
|
|
+ })
|
|
|
|
+ }
|
|
})
|
|
})
|