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.

111 lines
3.8 KiB

import Dialog from '../../../../miniprogram_npm/@vant/weapp/dialog/dialog';
const app = getApp()
const words = [];
Component({
data: {
result: [],
boxArr: new Array(6),
},
methods: {
startCp() {
wx.setStorageSync('brandData', this.data.boxArr)
wx.navigateTo({
url: `/pages/varComm/pages/brandRatio/index`,
})
},
getOpenID() {
wx.getUserInfo({
success: (res) => {
let userInfo = res.userInfo
console.log(res);
wx.login({
success: (res1) => {
let code = res1.code
wx.request({
url: 'http://cloud.sws010.com/api/WeiXinApp.ashx',
data: {
action: 'getOpenidByCode',
code: code,
version: '1',
nickName: userInfo.nickName
},
method: "get",
success: (res3) => {
app.globalData.request({
action: 'logOpenid',
openid: res3.data.Data.openid
}).then((yes) => {
console.log(yes);
}).catch(err => {
Dialog.alert({
title: '提示',
context: this,
message: '该页面需绑定后台账号后才可访问',
}).then(()=>{
wx.setStorageSync('openId',res3.data.Data.openid)
wx.navigateTo({
url: '../../pages/mine/pages/bindUser/index',
})
})
})
}
})
}
})
}
})
},
del(index) {
console.log(index);
console.log(123);
},
onChange(event) {
const {detail} = event
const result = []
if(detail.length>6){
console.log('至多六个');
return
}
for(let i of detail){
result.push(JSON.parse(i))
}
result.length = 6
this.setData({
result:detail,
boxArr:result
})
},
},
lifetimes: {
attached() {
//页面数据
// this.getOpenID()
app.globalData.request({
action: 'getUserBrand',
token: 't%2BrswgjvzGM=',
}).then(res => {
let arr = []
for (let i = 65; i <= 90; i++) {
arr.push({
name: String.fromCharCode(i),
data: []
});
}
for (let i of res) {
for (let j of arr) {
if (i.firstword == j.name) {
j.data.push(i)
}
}
}
this.setData({
mockData: arr
})
})
}
},
})