123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- import {
- get, post,
- } from '../../utils/http';
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- userInfo: {},
- current: 0,
- detail: {},
- id: '',
- fromList: "",
- visible: false,
- spinning: true
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- console.log(options)
- let current = 0,fromList = "";
- if(options.fromList == "1") {
- current = 2
- fromList = options.fromList
- }
- this.setData({
- id: options.id,
- current,
- fromList,
- userInfo: wx.getStorageSync('userInfo')
- })
- this.getSkinInfo(options.id);
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- /**
- * 切换状态
- */
- onTabsChange(e) {
- let current = e.currentTarget.dataset.id
- if (current == this.data.current) {
- return;
- }
- this.setData({
- current,
- // page: 1,
- }, () => {
- // this.getCoupon()
- })
- },
- /**
- * 获取检测记录详情
- * /api/user/skin_log_info
- */
- getSkinInfo(id) {
- return new Promise((resolve,reject) => {
- get('api/user/skin_log_info',{
- id
- },(res) => {
- if(res.data) {
- res.data.question.forEach((item) => {
- item.status = 0
- })
- this.setData({
- spinning: false,
- detail: res.data
- })
- }
- resolve(res)
- })
- })
-
- },
- /**
- * 点击切换问诊卡问题
- */
- onChangeStatus(e) {
- let index = e.currentTarget.dataset.index
- let status = e.currentTarget.dataset.status
- this.setData({
- ['detail.question[' + index + '].status']: status
- })
- },
- /**
- * 问诊卡不提交
- */
- onCancelUse() {
- this.setData({
- visible: true
- })
- },
- /**
- * 问诊卡确认提交
- */
- onConfirmUse() {
- let detail = this.data.detail;
- let flag = true;
- let ids = [];
- let values = [];
- detail.question.forEach(item => {
- if(item.status === undefined || item.status == 'undefined') {
- console.log('空')
- flag = false
- }
- ids.push(item.id)
- values.push(item.status)
- });
- if(!flag) {
- wx.showToast({
- title: '请选择完所有选项',
- icon: 'none'
- })
- return;
- }
- post('api/user/save_investigation',{
- analysis_id: detail.analysis_id,
- ids: ids.toString(),
- values: values.toString()
- },(res) => {
- wx.showToast({
- title: '提交成功',
- icon: 'none'
- })
- this.setData({
- visible: true,
- spinning: true
- },() => {
- this.getSkinInfo(detail.analysis_id).then((res) => {
- // this.setData({
- // current: 2
- // })
- })
- })
- console.log(res)
- })
- }
- })
|