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.
367 lines
14 KiB
367 lines
14 KiB
// pages/user/discount/answer_topic/answer_topic.js
|
|
const app = getApp()
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
// iphone_height:app.globalData.screenHeight,
|
|
step: 0, //0首页1答题2结果页
|
|
pic_list: [
|
|
{
|
|
title_url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b1ada37868a134ab219c9b2cf7fb7bfbf0e4e9da768.png",
|
|
btn1: {
|
|
url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b195f86adf1cc3e07c3d5e38ef85a276c10e5ddc860.png",
|
|
id: '1'
|
|
},
|
|
btn2: {
|
|
url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b195f8a0a04cc3e07c3d5e38ef85a276c10e5ddc860.png",
|
|
id: '2'
|
|
}
|
|
},
|
|
{
|
|
title_url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b195f8599a1cc3e07c3d5e38ef85a276c10e5ddc860.png",
|
|
btn1: {
|
|
url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b195f8cc676cc3e07c3d5e38ef85a276c10e5ddc860.png",
|
|
id: '3'
|
|
},
|
|
btn2: {
|
|
url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b195f7d01f20410f96c90f22a6a6ee4c1b64851ab55.png",
|
|
id: '4'
|
|
}
|
|
},
|
|
{
|
|
title_url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b195f832aaacc3e07c3d5e38ef85a276c10e5ddc860.png",
|
|
btn1: {
|
|
url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b195f8af5bccc3e07c3d5e38ef85a276c10e5ddc860.png",
|
|
id: '5'
|
|
},
|
|
btn2: {
|
|
url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b195f84ab10cc3e07c3d5e38ef85a276c10e5ddc860.png",
|
|
id: '6'
|
|
}
|
|
},
|
|
{
|
|
title_url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b195f87ca49cc3e07c3d5e38ef85a276c10e5ddc860.png",
|
|
btn1: {
|
|
url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b195f8bd3d4cc3e07c3d5e38ef85a276c10e5ddc860.png",
|
|
id: '7'
|
|
},
|
|
btn2: {
|
|
url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b195f8daf18cc3e07c3d5e38ef85a276c10e5ddc860.png",
|
|
id: '8'
|
|
}
|
|
},
|
|
],//全部选择题
|
|
answer_list: [],//第几道选择题列表
|
|
answer_index: 0,//第几道选择题下标
|
|
last_answer: [],//选择题结果数组
|
|
answer_piclist: [
|
|
{
|
|
url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2b83808e8b8a79bfe7ee712784b5de25c88f71deab.png"
|
|
},
|
|
{
|
|
url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2b8388773a8a79bfe7ee712784b5de25c88f71deab.png"
|
|
},
|
|
{
|
|
url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2b838cbb4f8a79bfe7ee712784b5de25c88f71deab.png"
|
|
},
|
|
{
|
|
url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2b8390cb7f73e3272c120072d298474562fb4c9375.png"
|
|
},
|
|
{
|
|
url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b307103744f5f39b6f781012e2af323ca4f0eecf111.png"
|
|
},
|
|
{
|
|
url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2b8397b7c673e3272c120072d298474562fb4c9375.png"
|
|
},
|
|
{
|
|
url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2b839a8ba773e3272c120072d298474562fb4c9375.png"
|
|
},
|
|
{
|
|
url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2b839da45873e3272c120072d298474562fb4c9375.png"
|
|
},
|
|
{
|
|
url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2b83a1e1ff4d106694ea02244bd19b4a64e16f138d.png"
|
|
},
|
|
{
|
|
url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2b83abc2704d106694ea02244bd19b4a64e16f138d.png"
|
|
},
|
|
{
|
|
url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2b83aedb904d106694ea02244bd19b4a64e16f138d.png"
|
|
},
|
|
{
|
|
url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2b83b45c94ae1a07efdb41747558031b8715bdc618.png"
|
|
},
|
|
{
|
|
url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2b83bd4878ae1a07efdb41747558031b8715bdc618.png"
|
|
},
|
|
{
|
|
url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2b83c136f1f34ea660275bb582f6c355f0a20f625a.png"
|
|
},
|
|
{
|
|
url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b3047a97f83788ba5f76578f12c69c7e700b2359e8a.png"
|
|
},
|
|
{
|
|
url: "https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2b83c7f7dbf34ea660275bb582f6c355f0a20f625a.png"
|
|
},
|
|
],//上半截图片
|
|
answer_piclist_index: 0,//当前呈现下标
|
|
picurl: '',
|
|
previewImage: [
|
|
"https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2c6a8bbaad6ce2999e3f480cc263f9ae23dbd36da1.jpg",
|
|
"https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2c6a921de19154e0ca4f47047df7f3b84d8eed1d27.jpg",
|
|
"https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2c6a97bf399154e0ca4f47047df7f3b84d8eed1d27.jpg",
|
|
"https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2c6aa3da9aadfa53d230af143cfa4f485b10219eda.jpg",
|
|
"https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b3070fe27da69a26c94f09e59eecb5db9a36a56b041.jpg",
|
|
"https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2c6abeb72601118e9b6b50f202bf29176e7d951eec.jpg",
|
|
"https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2c6ac88549510ff769aeb84272eb112d3eb03b6fd3.jpg",
|
|
"https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2c6ad58eeef5811a201efe472044297e3456b90e0a.jpg",
|
|
"https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2c6ae54229fc30d50537c9ebdc257f0aae66708ee8.jpg",
|
|
"https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2c6afdcec6f41a59769b0ed61302345e344157f6e5.jpg",
|
|
"https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2c6b076335b702113774d34aacc39d6290f16b3dae.jpg",
|
|
"https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2c6b0db9e9b702113774d34aacc39d6290f16b3dae.jpg",
|
|
"https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2c6b1800ea9862ac348bba5b9b263f84f76bcfea7e.jpg",
|
|
"https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2c6b243d5343f15ebaa119bfc38a3d770a6e3860fa.jpg",
|
|
"https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b31e041b3b888b557d0677ee5bf6be3a38e1d9a7dd9.jpg",
|
|
"https://mahuaimage2.oss-cn-qingdao.aliyuncs.com/mini_app/video/61b2c6b3c7c15796790e23af5f83470f34eb2aee0f0d2.jpg",
|
|
],//完整结果图片
|
|
btn_top: 10 //btn按钮top
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
oncouon() {
|
|
let activity_id = ["3425,3426,3427,3428"]
|
|
wx.navigateTo({
|
|
url: '/pages/user/discount/coupons/coupons?activity_id=' + activity_id,
|
|
})
|
|
},
|
|
onLoad: function (options) {
|
|
let iphone_height = app.globalData.screenHeight
|
|
|
|
console.log(iphone_height);
|
|
if (iphone_height <= 600) {
|
|
this.setData({
|
|
btn_top: 0
|
|
})
|
|
} else if (iphone_height >= 600 && iphone_height <= 700) {
|
|
this.setData({
|
|
btn_top: 4
|
|
})
|
|
} else if (iphone_height >= 700 && iphone_height <= 800) {
|
|
this.setData({
|
|
btn_top: 8
|
|
})
|
|
} else if (iphone_height >= 800 && iphone_height <= 850) {
|
|
this.setData({
|
|
btn_top: 10
|
|
})
|
|
}
|
|
else if (iphone_height >= 850) {
|
|
this.setData({
|
|
btn_top: 14
|
|
})
|
|
}
|
|
this.setData({
|
|
step: 0,
|
|
answer_index: 0,
|
|
answer_list: [],
|
|
last_answer: []
|
|
})
|
|
wx.showShareMenu({
|
|
withShareTicket: true,
|
|
menus: ['shareAppMessage', 'shareTimeline']
|
|
})
|
|
},
|
|
cancel() {
|
|
wx.showToast({
|
|
title: '重新测试',
|
|
icon:"loading",
|
|
mask:true,
|
|
duration:800
|
|
})
|
|
setTimeout(() => {
|
|
this.setData({
|
|
step: 1,
|
|
answer_index: 0,
|
|
answer_list: this.data.pic_list[0],
|
|
last_answer: []
|
|
})
|
|
}, 800);
|
|
},
|
|
look(e) {
|
|
wx.previewImage({
|
|
urls: [this.data.previewImage[this.data.answer_piclist_index]],
|
|
})
|
|
},
|
|
|
|
next(e) {
|
|
let id = e.currentTarget.dataset.id
|
|
this.data.last_answer.push(id)
|
|
if (this.data.answer_index >= 3) {
|
|
console.log(this.data.last_answer, 'last_answer');
|
|
wx.showLoading({
|
|
title: '正在生成',
|
|
mask: true
|
|
})
|
|
let abswer_arr = this.data.last_answer
|
|
if (abswer_arr[0] == '1' && abswer_arr[1] == '3' && abswer_arr[2] == '5' && abswer_arr[3] == '7') {
|
|
this.setData({
|
|
answer_piclist_index: 0
|
|
})
|
|
} else if (abswer_arr[0] == '1' && abswer_arr[1] == '3' && abswer_arr[2] == '5' && abswer_arr[3] == '8') {
|
|
this.setData({
|
|
answer_piclist_index: 1,
|
|
picurl: this.data.answer_piclist[this.data.answer_piclist_index].url
|
|
})
|
|
} else if (abswer_arr[0] == '1' && abswer_arr[1] == '3' && abswer_arr[2] == '6' && abswer_arr[3] == '7') {
|
|
this.setData({
|
|
answer_piclist_index: 2,
|
|
picurl: this.data.answer_piclist[this.data.answer_piclist_index].url
|
|
})
|
|
} else if (abswer_arr[0] == '1' && abswer_arr[1] == '3' && abswer_arr[2] == '6' && abswer_arr[3] == '8') {
|
|
this.setData({
|
|
answer_piclist_index: 3,
|
|
picurl: this.data.answer_piclist[this.data.answer_piclist_index].url
|
|
})
|
|
} else if (abswer_arr[0] == '1' && abswer_arr[1] == '4' && abswer_arr[2] == '5' && abswer_arr[3] == '7') {
|
|
this.setData({
|
|
answer_piclist_index: 4,
|
|
picurl: this.data.answer_piclist[this.data.answer_piclist_index].url
|
|
})
|
|
} else if (abswer_arr[0] == '1' && abswer_arr[1] == '4' && abswer_arr[2] == '5' && abswer_arr[3] == '8') {
|
|
this.setData({
|
|
answer_piclist_index: 5,
|
|
picurl: this.data.answer_piclist[this.data.answer_piclist_index].url
|
|
})
|
|
} else if (abswer_arr[0] == '1' && abswer_arr[1] == '4' && abswer_arr[2] == '6' && abswer_arr[3] == '7') {
|
|
this.setData({
|
|
answer_piclist_index: 6,
|
|
picurl: this.data.answer_piclist[this.data.answer_piclist_index].url
|
|
})
|
|
} else if (abswer_arr[0] == '1' && abswer_arr[1] == '4' && abswer_arr[2] == '6' && abswer_arr[3] == '8') {
|
|
this.setData({
|
|
answer_piclist_index: 7,
|
|
picurl: this.data.answer_piclist[this.data.answer_piclist_index].url
|
|
})
|
|
} else if (abswer_arr[0] == '2' && abswer_arr[1] == '3' && abswer_arr[2] == '5' && abswer_arr[3] == '7') {
|
|
this.setData({
|
|
answer_piclist_index: 8,
|
|
picurl: this.data.answer_piclist[this.data.answer_piclist_index].url
|
|
})
|
|
} else if (abswer_arr[0] == '2' && abswer_arr[1] == '3' && abswer_arr[2] == '5' && abswer_arr[3] == '8') {
|
|
this.setData({
|
|
answer_piclist_index: 9,
|
|
picurl: this.data.answer_piclist[this.data.answer_piclist_index].url
|
|
})
|
|
} else if (abswer_arr[0] == '2' && abswer_arr[1] == '3' && abswer_arr[2] == '6' && abswer_arr[3] == '7') {
|
|
this.setData({
|
|
answer_piclist_index: 10,
|
|
picurl: this.data.answer_piclist[this.data.answer_piclist_index].url
|
|
})
|
|
} else if (abswer_arr[0] == '2' && abswer_arr[1] == '3' && abswer_arr[2] == '6' && abswer_arr[3] == '8') {
|
|
this.setData({
|
|
answer_piclist_index: 11,
|
|
picurl: this.data.answer_piclist[this.data.answer_piclist_index].url
|
|
})
|
|
} else if (abswer_arr[0] == '2' && abswer_arr[1] == '4' && abswer_arr[2] == '5' && abswer_arr[3] == '7') {
|
|
this.setData({
|
|
answer_piclist_index: 12,
|
|
picurl: this.data.answer_piclist[this.data.answer_piclist_index].url
|
|
})
|
|
} else if (abswer_arr[0] == '2' && abswer_arr[1] == '4' && abswer_arr[2] == '5' && abswer_arr[3] == '8') {
|
|
this.setData({
|
|
answer_piclist_index: 13,
|
|
picurl: this.data.answer_piclist[this.data.answer_piclist_index].url
|
|
})
|
|
} else if (abswer_arr[0] == '2' && abswer_arr[1] == '4' && abswer_arr[2] == '6' && abswer_arr[3] == '7') {
|
|
this.setData({
|
|
answer_piclist_index: 14,
|
|
picurl: this.data.answer_piclist[this.data.answer_piclist_index].url
|
|
})
|
|
} else if (abswer_arr[0] == '2' && abswer_arr[1] == '4' && abswer_arr[2] == '6' && abswer_arr[3] == '8') {
|
|
this.setData({
|
|
answer_piclist_index: 15,
|
|
picurl: this.data.answer_piclist[this.data.answer_piclist_index].url
|
|
})
|
|
}
|
|
|
|
|
|
setTimeout(() => {
|
|
wx.hideLoading()
|
|
this.setData({
|
|
step: 2
|
|
})
|
|
}, 1000);
|
|
|
|
return
|
|
}
|
|
let answer_index = this.data.answer_index + 1
|
|
console.log(answer_index);
|
|
this.setData({
|
|
answer_index,
|
|
answer_list: this.data.pic_list[answer_index]
|
|
})
|
|
},
|
|
get_step(e) {
|
|
// console.log(e);
|
|
let step = e.currentTarget.dataset.step
|
|
this.setData({
|
|
answer_list: this.data.pic_list[0],
|
|
step: 1
|
|
})
|
|
},
|
|
|
|
getshare() {
|
|
this.onShareAppMessage(1)
|
|
wx.showShareMenu();
|
|
},
|
|
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
|
|
}) |