123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- var util = require("../../utils/util.js")
- const app = getApp()
- Page({
- data: {
- question: [],
- },
- onLoad: function(options) {
- this._getQuestion();
- this.setData({
- navH: app.globalData.navHeight
- })
- },
- // 获取题目信息
- _getQuestion: function() {
- util.getData('/getWXMMSearchQuestion')
- .then(res => {
- this.setData({
- question: res
- })
- })
- .catch(err => {
- console.log(err);
- })
- },
- // 选择题选择
- _selectItem: function(e) {
- let index = e.currentTarget.dataset.index;
- let subid = e.currentTarget.dataset.subid;
- this.editQuestion(index, subid);
- },
- // 输入框输入or日期选择
- _bindKeyInput: function(e) {
- let index = e.currentTarget.dataset.index;
- let subid = e.currentTarget.dataset.subid;
- let txt = e.detail.value;
- this.editQuestion(index, subid, txt);
- },
- // 输入or选择 信息录入
- editQuestion: function(index, subid, txt) {
- let type = this.data.question[index].wsq_type;
- let question = this.data.question;
- this.data.question[index].wxmmSearchAnswerList.forEach((item, itemInd) => {
- if (type == 2) {
- item.id == subid ? item.is_select = 1 : item.is_select = 0;
- } else {
- item.id == subid ? item.is_select = txt : '';
- }
- let attr = `question[${index}].wxmmSearchAnswerList[${itemInd}]`;
- this.setData({
- [attr]: item
- })
- })
- },
- // 获取时间
- formatDate: function() {
- let date = new Date();
- let year = date.getFullYear().toString().padStart(2, '0');
- let month = (date.getMonth() + 1).toString().padStart(2, '0');
- let day = date.getDate().toString().padStart(2, '0');
- return `${year}-${month}-${day}`
- },
- // 提交信息
- _clickBtn: function() {
- let question = this.data.question;
- let stopRun = false;
- let branche_code = wx.getStorageSync('branche_code');
- let params = {
- wmu_openid: app.globalData.openid,
- wmu_phone: app.globalData.userphone,
- wmu_city: branche_code,
- wmu_date: this.formatDate(),
- wxMMUserSearchDetails: []
- }
- question.some((item, index) => {
- let isstop = false;
- let selectBool = item.wsq_type == 2 ? false : true;
- item.wxmmSearchAnswerList.some((itemAns, indAns) => {
- let tempObj = {
- wmud_qid: itemAns.wma_question_id,
- wmud_aid: itemAns.id
- }
- if (item.wsq_type == 2) {
- // 选择题处理
- if (itemAns.is_select) {
- tempObj.wmud_value = itemAns.wma_value;
- params.wxMMUserSearchDetails.push(tempObj);
- selectBool = true;
- }
- } else {
- // 非选择题
- if(item.id!==10){
- if (!itemAns.is_select) {
- isstop = true;
- return true;
- } else {
- tempObj.wmud_value = itemAns.is_select;
- params.wxMMUserSearchDetails.push(tempObj);
- }
- }else{
- tempObj.wmud_value = itemAns.is_select;
- params.wxMMUserSearchDetails.push(tempObj);
- }
-
- }
- })
- if (!selectBool || isstop) {
- wx.showToast({
- title: '为了更好的为您推荐月嫂,请填写完整',
- icon: 'none',
- duration: 2000
- })
- stopRun = true;
- return true;
- }
- })
- if (!stopRun) {
- wx.request({
- url: app.globalData.url + '/queryUserMMSearch',
- data: params,
- header: {
- "Content-Type": "application/json"
- },
- method: "POST",
- success: function(res) {
- wx.setStorageSync('MMSearch', JSON.stringify(res));
- wx.setStorageSync(
- 'yslist', res.data
- )
- wx.navigateTo({
- url: '/pages/monthmama/monthmama'
- })
- }
- })
- }
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function() {}
- })
|