秦杰 6 年 前
コミット
ad13c15dfc

ファイルの差分が大きいため隠しています
+ 0 - 0
.wepycache


+ 1 - 2
package.json

@@ -11,8 +11,7 @@
     "test": "echo \"Error: no test specified\" && exit 1"
   },
   "wepy": {
-    "module-a": false,
-    "./src/components/list": "./src/components/wepy-list.wpy"
+    "module-a": false
   },
   "author": "",
   "license": "MIT",

+ 4 - 2
src/app.wpy

@@ -62,7 +62,7 @@ export default class extends wepy.app {
 
   globalData = {
     userInfoCanUse: false,
-    userInfo: null
+    userInfo: {}
   };
 
   constructor() {
@@ -76,7 +76,7 @@ export default class extends wepy.app {
 
   getUserInfo(cb) {
     const that = this;
-    if (this.globalData.userInfo) {
+    if (this.globalData.userInfo.nickName) {
       cb(this.globalData.userInfo);
       return this.globalData.userInfo;
     }
@@ -85,8 +85,10 @@ export default class extends wepy.app {
         if (res.authSetting['scope.userInfo']) {
           wx.getUserInfo({
             success: function(res) {
+              // console.log(res)
               that.globalData.userInfo = Object.assign({},that.globalData.userInfo,res.userInfo);
               that.globalData.userInfoCanUse = true;
+              that.globalData.mobile = wepy.getStorageSync("phoneNumber");
               cb && cb(res.userInfo);
             }
           });

+ 12 - 2
src/components/exchange.wpy

@@ -69,7 +69,7 @@
     <view class="exchange-layer" style="display:{{show?'block':'none'}}">
       <form bindsubmit="doExchange">
       <text class="h1">输入兑换码</text>
-      <input type="text" name="code" value="{{code}}"/>
+      <input type="text" name="code" />
       <view class="tip" wx:if="{{tip}}">{{tip}}</view>
       <view class="btns"><view class="btn primary">兑换<button formType="submit"></button></view></view>
       <view class="close" @tap="closelayer"></view>
@@ -110,7 +110,17 @@ export default class Exchange extends wepy.component {
               self.tip = d.msg;
               self.$apply();
             }else{
-              self.$emit('exchange-res', 1);
+              // self.$emit('exchange-res', 1);
+              wx.showToast({
+                title:"兑换成功"
+              })
+              self.show = false;
+              self.tip = '';
+              self.code = '';
+              self.$apply();
+              wx.switchTab({
+                url: '/pages/myserve'
+              });
             }
           }
         })

+ 9 - 4
src/components/login.wpy

@@ -7,8 +7,12 @@
   left: 0;
   top: 0;
   background-color: #fff;
+  display: flex;
+  flex-direction: column;
+  justify-content: center;
+  align-items: center;
   .cover {
-    width: 750rpx;
+    width: 450rpx;
   }
   .ctrls {
     padding-top: 58rpx;
@@ -39,7 +43,7 @@
 </style>
 <template>
   <view class="login-container" wx:if="{{show}}">
-    <image class="cover" src="http://app.jiazhihome.com/data/upload/1/2018/09/02/4b1c59c7728e2b1cb65f6cb20aaf5cf9.jpg" mode="widthFix" />
+    <image class="cover" src="http://app.jiazhihome.com/data/upload/1/2018/09/04/844e20538e57f0c46356efbb7896007c.gif" mode="widthFix" />
     <view class="ctrls">
         <text>授权后才可以使用进行家芝软装服务\n感谢您的支持</text>
         <view class="btn primary">登录授权<button open-type="getUserInfo" lang="zh_CN" bindgetuserinfo="onGotUserInfo">获取用户信息</button></view>
@@ -62,8 +66,9 @@ export default class Login extends wepy.component {
   methods = {
     onGotUserInfo: function(e) {
       let userInfo = JSON.parse(e.detail.rawData);
-      this.$parent.userInfoCanUse = true;
-      this.$parent.$apply();
+      // this.$parent.userInfoCanUse = true;
+      // this.$parent.$apply();
+      this.$emit("userInfoCall",userInfo)
       this.show = false;
       this.callback();
       

+ 102 - 0
src/components/phoneNumber.wpy

@@ -0,0 +1,102 @@
+<style lang="scss">
+@import '../assets/css/common.scss';
+.login-container {
+  position: fixed;
+  width: 100%;
+  height: 100%;
+  left: 0;
+  top: 0;
+  background-color: #fff;
+  display: flex;
+  flex-direction: column;
+  justify-content: center;
+  align-items: center;
+  .cover {
+    width: 450rpx;
+  }
+  .ctrls {
+    padding-top: 58rpx;
+    text {
+      display: block;
+      text-align: center;
+      font-size: 30rpx;
+      line-height: 45rpx;
+      font-weight: bolder;
+      margin-bottom: 58rpx;
+    }
+    .btn {
+      width: 480rpx;
+      line-height: 90rpx;
+      position: relative;
+      margin: 0 auto;
+      button {
+        position: absolute;
+        width: 100%;
+        height: 100%;
+        left: 0;
+        top: 0;
+        opacity: 0;
+      }
+    }
+  }
+}
+</style>
+<template>
+  <view class="login-container" wx:if="{{show}}">
+    <image class="cover" src="http://app.jiazhihome.com/data/upload/1/2018/09/04/844e20538e57f0c46356efbb7896007c.gif" mode="widthFix" />
+    <view class="ctrls">
+        <text>授权后才可以使用进行家芝软装服务\n感谢您的支持</text>
+        <view class="btn primary">手机号认证<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber"> </button> </view>
+    </view>
+  </view>
+</template>
+
+<script>
+import wepy from 'wepy';
+
+export default class Login extends wepy.component {
+  data = {
+    show: false,
+    callback: function() {}
+  };
+  components = {};
+  computed = {};
+  watch = {};
+
+  methods = {
+    getPhoneNumber: function(e) {
+      let self = this;
+      self.$parent.request('/passport/?l=applet.mobile', {
+        data: {
+          iv: e.detail.iv,
+          encryptedData: e.detail.encryptedData,
+          uid: wepy.getStorageSync('uid'),
+          vid: wepy.getStorageSync('vid')
+        },
+        success: function(d) {
+          let data = d.data.data;
+          self.show = false;
+          self.$emit("phoneNumberCall",data.mobile)
+          self.callback();
+          self.$apply()
+          // console.log(data)
+          //   self.$parent.userInfo.phoneNumber = data.mobile;
+        }
+      });
+    },
+    show(callback) {
+      this.show = true;
+      this.callback = callback;
+      this.$apply();
+    },
+    hide() {
+      this.show = false;
+      this.$apply();
+    }
+  };
+
+  events = {};
+
+  onLoad() {}
+}
+</script>

+ 53 - 29
src/mixins/base.js

@@ -8,32 +8,44 @@ export default class baseMixin extends wepy.mixin {
   methods = {
     doExchange(e) {
       let self = this;
-      if (!this.$parent.globalData.userInfoCanUse) {
-        this.$invoke('login', 'show', function () {
-          self.$invoke('exchange', 'show', e.currentTarget.dataset.id);
-        });
-      } else {
-        this.$invoke('exchange', 'show', e.currentTarget.dataset.id);
-      }
+      this.validExchange(function(){
+        self.$invoke('exchange', 'show', e.currentTarget.dataset.id);
+      })
     },
-    pay(e) {
+    handlePay(e) {
+      // console.log('pay')
       let self = this;
-      if (!this.$parent.globalData.userInfoCanUse) {
-        this.$invoke('login', 'show', function () {
-          self.doPay(e.currentTarget.dataset.id)
-        });
-      } else {
-        this.doPay(e.currentTarget.dataset.id)
-      }
+      this.validExchange(function(){
+        self.doPay(e.currentTarget.dataset.id)
+      })
     }
   }
   events = {
-    'showlogin': (res) => {
+    'userInfoCall': function(res) {
+      this.$parent.globalData.userInfo = res;
+      this.$parent.globalData.userInfoCanUse = true;
+    },
+    'phoneNumberCall': function(res) {
+      this.$parent.globalData.mobile = res;
+      wepy.setStorageSync("phoneNumber", res);
+    }
+  };
+
+  validExchange(callback){
+    let self = this;
+    // console.log(this.$parent.globalData)
+    if (!this.$parent.globalData.userInfoCanUse) {
       this.$invoke('login', 'show', function () {
-        console.log('dfsfds')
+        self.validExchange(callback)
+      });
+    }else if (!self.$parent.globalData.mobile){
+      this.$invoke('phoneNumber', 'show', function () {
+        self.validExchange(callback)
       });
+    } else {
+      callback()
     }
-  };
+  }
 
   doPay(product_id) {
     let self = this;
@@ -42,16 +54,28 @@ export default class baseMixin extends wepy.mixin {
         product_id: product_id
       },
       success(res) {
-        let payData = res.data.data.pay;
-        wx.requestPayment({
-          'timeStamp': payData.time,
-          'nonceStr': payData.nonce_str,
-          'package': `prepay_id=${payData.prepay_id}`,
-          'signType': payData.sign_type,
-          'paySign': payData.sign,
-          'success': function (res) {},
-          'fail': function (res) {}
-        })
+        if(res.data.status == 1){
+          let payData = res.data.data.pay;
+          wx.requestPayment({
+            'timeStamp': payData.time,
+            'nonceStr': payData.nonce_str,
+            'package': `prepay_id=${payData.prepay_id}`,
+            'signType': payData.sign_type,
+            'paySign': payData.sign,
+            'success': function (res) {
+              wx.switchTab({
+                url: '/pages/myserve'
+              });
+            },
+            'fail': function (res) {}
+          })
+        }else{
+          wx.showToast({
+            title: res.data.msg,
+            icon: 'none',
+            duration: 2000
+          })
+        }
       }
     })
   }
@@ -81,7 +105,7 @@ export default class baseMixin extends wepy.mixin {
       self.$parent.globalData.signature = signature;
       self.$parent.globalData.uid = wepy.getStorageSync("uid");
       self.$parent.globalData.vid = wepy.getStorageSync("vid");
-      self.$parent.globalData.phoneNumber = wepy.getStorageSync("phoneNumber");
+      self.$parent.globalData.mobile = wepy.getStorageSync("phoneNumber");
       self.sign = true;
       cb()
     } else {

ファイルの差分が大きいため隠しています
+ 16 - 2
src/pages/cases.wpy


+ 65 - 38
src/pages/feedback.wpy

@@ -44,7 +44,7 @@
     }
     .goods-list {
       padding-top: 43rpx;
-      border-bottom: 1rpx solid #e5e5e5;
+      // border-bottom: 1rpx solid #e5e5e5;
     }
     .goods {
       display: flex;
@@ -109,61 +109,52 @@
   .p {
     font-size: 26rpx;
   }
+  .btn{
+    position: relative;
+    button{
+      position: absolute;
+      top: 0;
+      left:0;
+      width: 100%;
+      height: 100%;
+      opacity: 0;
+    }
+  }
 }
 </style>
 <template>
   <view class="container">
     <view class="article">
         <view class="h1">
-            <text>软装服务介绍</text>
+            <text>{{feedback.name}}</text>
         </view>
-        <image class="banner" src="http://192.168.11.108/assets/jiazhi/tmp1.jpg" mode="widthFix" />
+        <image class="banner" src="{{feedback.pic}}" mode="widthFix" />
         <view class="btns">
-            <view class="btn primary">浏览详细方案</view>
+            <view class="btn primary" @tap="openPDF">浏览详细方案</view>
         </view>
     </view>
     <view class="list">
         <view class="h2">软装商品清单</view>
         <view class="goods-list">
-            <view class="goods">
-                <image src="http://192.168.11.108/assets/jiazhi/tmp2.jpg" />
+            <view class="goods" wx:for="{{feedback.product}}">
+                <image src="{{item.pic}}" />
                 <view>
-                    <text>商品名称商品名称商品名称商品品名称</text>
+                    <text>{{item.name}}</text>
                     <view>
-                        <text>¥599</text>
-                        <view class="btn min primary">购买</view>
-                    </view>
-                </view>
-            </view>
-            <view class="goods">
-                <image src="http://192.168.11.108/assets/jiazhi/tmp2.jpg" />
-                <view>
-                    <text>商品名称商品名称商品名称商品品名称</text>
-                    <view>
-                        <text>¥599</text>
-                        <view class="btn min primary">购买</view>
-                    </view>
-                </view>
-            </view>
-            <view class="goods">
-                <image src="http://192.168.11.108/assets/jiazhi/tmp2.jpg" />
-                <view>
-                    <text>商品名称商品名称商品名称商品品名称</text>
-                    <view>
-                        <text>¥599</text>
-                        <view class="btn min primary">购买</view>
+                        <text>¥{{item.price}}</text>
+                        <navigator wx:if="{{item.link}}" url="/pages/artice?url={{item.link}}" class="btn min primary">购买</navigator>
                     </view>
                 </view>
             </view>
         </view>
-        <view class="more">
+        <!-- <view class="more">
             <navigator>查看全部4件商品》</navigator>
-        </view>
+        </view> -->
     </view>
     <view class="bbar">
         <view class="btns">
-            <view class="btn">在线客服</view>
-            <view class="btn" @tap="openPDF">打开PDF</view>
+            <view class="btn">在线客服<button open-type="contact"></button></view>
+            <!-- <view class="btn" @tap="downPDF">下载PDF</view> -->
         </view>
     </view>
   </view>
@@ -171,6 +162,7 @@
 
 <script>
 import wepy from 'wepy';
+import baseMixin from '../mixins/base';
 
 export default class Feedback extends wepy.page {
   config = {
@@ -178,7 +170,7 @@ export default class Feedback extends wepy.page {
   };
 
   data = {
-    cases: []
+    feedback: []
   };
   components = {};
   computed = {
@@ -186,23 +178,45 @@ export default class Feedback extends wepy.page {
       return +new Date();
     }
   };
+  mixins = [baseMixin];
 
   methods = {
     openPDF() {
-        console.log('in..')
+      wx.showLoading({
+        title:"加载中...",
+        mask:true
+      })
       wx.downloadFile({
-        url: 'http://192.168.11.108/assets/jiazhi/doc.pdf',
+        url: this.feedback.pdf,
         success: function(res) {
           var filePath = res.tempFilePath;
-          console.log(filePath)
           wx.openDocument({
             filePath: filePath,
             success: function(res) {
               console.log('打开文档成功');
+              wx.hideLoading();
             }
           });
         }
       });
+    },
+    downloadPDF() {
+      wx.showLoading({
+        title:"下载中...",
+        mask:true
+      })
+      wx.downloadFile({
+        url: this.feedback.pdf,
+        success: function(res) {
+          var filePath = res.tempFilePath;
+          wx.hideLoading();
+          wx.showToast({
+            title: '下载成功',
+            icon: 'success',
+            duration: 2000
+          })
+        }
+      });
     }
   };
 
@@ -212,6 +226,19 @@ export default class Feedback extends wepy.page {
     }
   };
 
-  onLoad() {}
+  onLoad(options) {
+    // 
+    let self = this;
+    self.request('/service/?l=api.feedback', {
+      data:{
+        id:options.id
+      },
+      success: function(d) {
+        let data = d.data.data;
+        self.feedback = data.feedback;
+        self.$apply();
+      }
+    });
+  }
 }
 </script>

+ 23 - 14
src/pages/index.wpy

@@ -106,7 +106,7 @@
         color: #ff5037;
         margin-left: 13rpx;
       }
-      navigator {
+      .navigator {
         font-weight: normal;
         font-size: 24rpx;
         text-decoration: underline;
@@ -149,10 +149,10 @@
         </block>
     </swiper>
     <view class="desc">
-        <view class="title">软装服务是什么?</view>
-        <view class="text">软装是“家的造型师”。相对于硬装敲墙打地,软装通过色彩、布局、家具家居饰品的搭配,简单轻松的让家变美变舒适。</view>
+        <view class="title">{{config.desc_name}}</view>
+        <view class="text">{{config.desc_content}}</view>
     </view>
-    <view class="liuc-tit">家芝软装服务流程</view>
+    <view class="liuc-tit">{{config.flow_name}}</view>
     <view class="liuc">
         <view class="task">
             <text>软装任务</text>
@@ -167,31 +167,33 @@
             <text>改造反馈</text>
         </view>
     </view>
-    <view class="card" wx:for="{{product}}">
+    <view @tap="toServeDetail" data-url="/pages/servedetail?id={{item.id}}" class="card" wx:for="{{product}}">
         <image src="{{item.pics[0]}}" mode="widthFix" />
         <view class="cont">
-            <view class="tit"><view>{{item.name}}<text class="prize">{{item.price}}</text></view><navigator url="/pages/servedetail?id={{item.id}}">查看详情</navigator></view>
+            <view class="tit"><view>{{item.name}}<text class="prize">{{item.price}}元</text></view><view class="navigator">查看详情</view></view>
             <view class="p">{{item.info}}</view>
         </view>
         <view class="btns">
-            <view class="btn primary" wx:if="{{item.type2}}" @tap="doExchange" data-id="{{item.id}}">免费兑换</view>
-            <view class="btn" @tap="pay" wx:if="{{item.type1}}" data-id="{{item.id}}" data-cash="{{item.cash}}">购买</view>
+            <view class="btn primary" wx:if="{{item.type2}}" @tap.capture.stop="doExchange" data-id="{{item.id}}">免费兑换</view>
+            <view class="btn" @tap.capture.stop="handlePay" wx:if="{{item.type1}}" data-id="{{item.id}}" data-cash="{{item.cash}}">购买</view>
         </view>
     </view>
     <view class="tip">
-        还没有兑换码,马上参与<navigator>软装任务</navigator>
+        还没有兑换码,马上参与<navigator url="/pages/article?url={{config.article}}">软装任务</navigator>
     </view>
     <!-- <footer></footer> -->
     <exchange></exchange>
     <login></login>
+    <phoneNumber></phoneNumber>
   </view>
 </template>
 
 <script>
 import wepy from 'wepy';
-import Footer from '../components/footer';
+// import Footer from '../components/footer';
 import Exchange from '../components/exchange';
 import Login from '../components/login';
+import PhoneNumber from '../components/phoneNumber';
 import baseMixin from '../mixins/base';
 
 export default class Index extends wepy.page {
@@ -201,22 +203,28 @@ export default class Index extends wepy.page {
 
   data = {
     focus:{},
-    product:[]
+    product:[],
+    config:{}
   };
 
   mixins = [baseMixin];
 
   components = {
-    footer: Footer,
+    // footer: Footer,
     exchange: Exchange,
-    login: Login
+    login: Login,
+    phoneNumber:PhoneNumber
   };
   computed = {
     
   };
 
   methods = {
-    
+    toServeDetail(e){
+      wx.navigateTo({
+        url: e.currentTarget.dataset.url
+      })
+    }
   };
 
   events = {
@@ -230,6 +238,7 @@ export default class Index extends wepy.page {
       success: function(d) {
         let data = d.data.data;
         self.focus = data.focus;
+        self.config = data.config;
         data.product.map(pro =>{
           let types = pro.type.split(',');
           pro.pics = pro.pic.split(',')

+ 43 - 12
src/pages/myserve.wpy

@@ -42,10 +42,18 @@
     }
   }
 }
+.nores{
+  position: fixed;
+  width: 100%;
+  height: 100%;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+}
 </style>
 <template>
   <view class="container">
-      <view class="servelist">
+      <view class="servelist" wx:if="{{orderlen > 0}}">
         <view class="serve" wx:for="{{order}}">
             <view class="h2">{{item.name}}</view>
             <view class="box">
@@ -57,25 +65,34 @@
                 </block>
                 <block wx:if="{{item.feedback_status == 2}}">
                   <view class="msg">
-                    <text class="tip">需求填写完成,可继续补充资料</text>
-                    <text>等待设计反馈</text>
+                    <text class="tip">填写问卷中</text>
+                    <text>有效期至:{{item.edate}}</text>
                   </view>
                   </block>
                   <block wx:if="{{item.feedback_status == 3}}">
                     <view class="msg">
-                  <view class="tip">继续沟通,补充<navigator url="/pages/material">完善资料</navigator></view>
-                    <text>设计已反馈</text>
+                      <view class="tip">完成问卷,等待方案</view>
+                      <text>等待设计反馈</text>
+                    </view>
+                  </block>
+                  <block wx:if="{{item.feedback_status == 4}}">
+                    <view class="msg">
+                      <view class="tip">服务获取成功</view>
+                      <text>设计已反馈</text>
                     </view>
                   </block>
                 <view>
                     <block wx:if="{{item.feedback_status == 1}}">
-                      <navigator url="/pages/questions?product_id={{item.product_id}}" class="btn primary">填写问卷</navigator>
+                      <navigator url="/pages/questions?order_id={{item.id}}&product_id={{item.product_id}}" class="btn primary">填写问卷</navigator>
                     </block>
                     <block wx:if="{{item.feedback_status == 2}}">
-                      <navigator url="/pages/material" class="btn primary">补充资料</navigator>
+                      <navigator url="/pages/questions?order_id={{item.id}}&product_id={{item.product_id}}" class="btn primary">继续填写</navigator>
                     </block>
-                    <block wx:if="{{item.feedback_status == 3}}">
-                      <navigator url="/pages/feedback" class="btn primary">查看方案</navigator>
+                    <!-- <block wx:if="{{item.feedback_status == 2}}">
+                      <navigator url="/pages/material" class="btn primary">补充资料</navigator>
+                    </block> -->
+                    <block wx:if="{{item.feedback_status == 4}}">
+                      <navigator url="/pages/feedback?id={{item.feedback_id}}" class="btn primary">查看方案</navigator>
                     </block>
                 </view>
             </view>
@@ -105,6 +122,7 @@
             </view>
         </view> -->
     </view>
+    <view class="nores" wx:else><text>您还没有家芝软装服务订单!</text></view>
     <!-- <footer active="serve"></footer> -->
     <login></login>
   </view>
@@ -118,10 +136,12 @@ import baseMixin from '../mixins/base';
 
 export default class MyServe extends wepy.page {
   config = {
-    navigationBarTitleText: '家芝'
+    navigationBarTitleText: '家芝',
+    // enablePullDownRefresh:true
   };
 
   data = {
+    orderlen:0,
     order: {}
   };
   components = {
@@ -140,9 +160,19 @@ export default class MyServe extends wepy.page {
   events = {};
 
   onShow() {
-    !this.inited && this.initFunc()
+    /*!this.inited && */this.initFunc()
+  }
+  onPullDownRefresh(){
+    this.request('/service/?l=api.order', {
+      success: (d) => {
+        let data = d.data.data;
+        this.order = data.order;
+        this.inited = true;
+        this.$apply();
+        wx.stopPullDownRefresh();
+      }
+    });
   }
-
   initFunc() {
     this.$parent.getUserInfo(userinfo => {
       this.userInfo = Object.assign({}, userinfo);
@@ -156,6 +186,7 @@ export default class MyServe extends wepy.page {
           success: (d) => {
             let data = d.data.data;
             this.order = data.order;
+            this.orderlen = Object.keys(this.order).length;
             this.inited = true;
             this.$apply();
           }

+ 119 - 32
src/pages/questions.wpy

@@ -67,7 +67,7 @@
 .question {
   width: 100%;
   box-sizing: border-box;
-  padding: 86rpx 62rpx 0;
+  padding: 0 62rpx 0;
   .h1 {
     color: #ff5037;
     font-size: 48rpx;
@@ -121,6 +121,7 @@
       width: 34rpx;
       height: 34rpx;
       margin-right: 18rpx;
+      flex-shrink: 0;
     }
     &.checked {
       &:before {
@@ -162,7 +163,7 @@
         align-items: center;
         &:before {
           content: '';
-          background: url(http://192.168.11.108/assets/jiazhi/ico-add.png)
+          background: url(http://app.jiazhihome.com/data/upload/1/2018/09/03/1176fca0e23735499d23bf9892509c40.png)
             no-repeat;
           background-size: cover;
           display: block;
@@ -251,6 +252,14 @@
             display: flex;
             justify-content: space-between;
             padding-right: 20rpx;
+            overflow: hidden;
+            white-space: nowrap;
+            flex-shrink: 0;
+            text{
+              width: 80%;
+              overflow: hidden;
+              text-overflow: ellipsis;
+            }
             &:after {
               content: '';
               width: 0;
@@ -311,10 +320,10 @@
                 <text>{{product.question_name}}</text>
             </view>
             <view class="p"><rich-text nodes="{{product.question_content}}"></rich-text></view>
-            <view class="tips">
+            <!-- <view class="tips">
                 <text>温馨提示:\n{{product.question_desc}}</text>
-            </view>
-            <image class="banner" src="{{product.question_pic}}" mode="widthFix" />
+            </view> -->
+            <image class="banner" wx:if="{{product.question_pic}}" src="{{product.question_pic}}" mode="widthFix" />
         </view>
         <view class="bbar">
             <view class="btns">
@@ -354,7 +363,7 @@
                   <view @tap="handleTap" data-qid="{{index}}" data-type="single" data-optKey="{{option_key}}" class="item" wx:for="{{item.content}}" wx:for-item="option" wx:for-index="option_key"><image wx:if="{{option.pic}}" src="{{option.pic}}" /><text class="ico-radio {{option.checked?'checked':''}}">{{option.title}}</text></view>
                 </block>
                 <block wx:else>
-                  <view @tap="handleTap" data-qid="{{index}}" data-type="single" data-optKey="{{option_key}}" class="ico-radio {{option.checked?'checked':''}}" wx:for="{{item.content}}" wx:for-item="option" wx:for-index="option_key">{{option.title}}<input type="text" wx:if="{{option.ctype[0] == 2}}"/></view>
+                  <view @tap="handleTap" data-qid="{{index}}" data-type="single" data-optKey="{{option_key}}" class="ico-radio {{option.checked?'checked':''}}" wx:for="{{item.content}}" wx:for-item="option" wx:for-index="option_key">{{option.title}}<input type="text" value="{{option.value}}" @input="handleOtherInput" data-qid="{{index}}" data-optKey="{{option_key}}" wx:if="{{option.ctype[0] == 2}}"/></view>
                 </block>
             </view>
           </block>
@@ -364,7 +373,7 @@
                   <view @tap="handleTap" data-qid="{{index}}" data-type="mult" data-optKey="{{option_key}}" class="item" wx:for="{{item.content}}" wx:for-item="option" wx:for-index="option_key"><image wx:if="{{option.pic}}" src="{{option.pic}}" /><text class="ico-checkbox {{option.checked?'checked':''}}">{{option.title}}</text></view>
                 </block>
                 <block wx:else>
-                  <view @tap="handleTap" data-qid="{{index}}" data-type="mult" data-optKey="{{option_key}}" class="ico-checkbox {{option.checked?'checked':''}}" wx:for="{{item.content}}" wx:for-item="option" wx:for-index="option_key">{{option.title}}<input type="text" wx:if="{{option.ctype[0] == 2}}"/></view>
+                  <view @tap="handleTap" data-qid="{{index}}" data-type="mult" data-optKey="{{option_key}}" class="ico-checkbox {{option.checked?'checked':''}}" wx:for="{{item.content}}" wx:for-item="option" wx:for-index="option_key">{{option.title}}<input type="text" value="{{option.value}}" @input="handleOtherInput" @focus="inputFocus" data-qid="{{index}}" data-optKey="{{option_key}}" @tap.capture="propagation" wx:if="{{option.ctype[0] == 2}}"/></view>
                 </block>
             </view>
           </block>
@@ -481,7 +490,7 @@
                     <view @tap="handleTap" data-qid="{{index}}" data-type="single" data-optKey="{{option_key}}" class="item" wx:for="{{item.content}}" wx:for-item="option" wx:for-index="option_key"><image wx:if="{{option.pic}}" src="{{option.pic}}" /><text class="ico-radio {{option.checked?'checked':''}}">{{option.title}}</text></view>
                   </block>
                   <block wx:else>
-                    <view @tap="handleTap" data-qid="{{index}}" data-type="single" data-optKey="{{option_key}}" class="ico-radio {{option.checked?'checked':''}}" wx:for="{{item.content}}" wx:for-item="option" wx:for-index="option_key">{{option.title}}<input type="text" wx:if="{{option.ctype[0] == 2}}"/></view>
+                    <view @tap="handleTap" data-qid="{{index}}" data-type="single" data-optKey="{{option_key}}" class="ico-radio {{option.checked?'checked':''}}" wx:for="{{item.content}}" wx:for-item="option" wx:for-index="option_key">{{option.title}}<input type="text" value="{{option.value}}" @input="handleOtherInput" data-qid="{{index}}" data-optKey="{{option_key}}" @tap.capture.stop="propagation" wx:if="{{option.ctype[0] == 2}}"/></view>
                   </block>
               </view>
             </block>
@@ -492,10 +501,23 @@
                     <view @tap="handleTap" data-qid="{{index}}" data-type="mult" data-optKey="{{option_key}}" class="item" wx:for="{{item.content}}" wx:for-item="option" wx:for-index="option_key"><image wx:if="{{option.pic}}" src="{{option.pic}}" /><text class="ico-checkbox {{option.checked?'checked':''}}">{{option.title}}</text></view>
                   </block>
                   <block wx:else>
-                    <view @tap="handleTap" data-qid="{{index}}" data-type="mult" data-optKey="{{option_key}}" class="ico-checkbox {{option.checked?'checked':''}}" wx:for="{{item.content}}" wx:for-item="option" wx:for-index="option_key">{{option.title}}<input type="text" wx:if="{{option.ctype[0] == 2}}"/></view>
+                    <view @tap="handleTap" data-qid="{{index}}" data-type="mult" data-optKey="{{option_key}}" class="ico-checkbox {{option.checked?'checked':''}}" wx:for="{{item.content}}" wx:for-item="option" wx:for-index="option_key">{{option.title}}<input type="text" value="{{option.value}}" @input="handleOtherInput" data-qid="{{index}}" data-optKey="{{option_key}}" @tap.capture.stop="propagation" wx:if="{{option.ctype[0] == 2}}"/></view>
                   </block>
               </view>
             </block>
+            <block wx:if="{{item.type == 11}}">
+              <view class="form-item">
+                <view class="label">{{item.name}}<text class="notify">{{item.info}}</text></view>
+                  <picker mode="region" bindchange="bindRegionChange" data-qid="{{index}}" value="{{item.region}}" custom-item="{{customItem}}">
+                    <view class="multi address">
+                      <view><text>{{item.region[0]}}</text></view>
+                      <view><text>{{item.region[1]}}</text></view>
+                      <view><text>{{item.region[2]}}</text></view>
+                    </view>
+                  </picker>
+            </view> 
+              
+            </block>
           </view>
             <!-- <view class="form-item">
                 <view class="label">姓名</view>
@@ -548,7 +570,9 @@ export default class Questions extends wepy.page {
     product: {},
     info: {},
     user: {},
-    page_number: 1
+    page_number: 1,
+    region: ['北京市', '北京市', '朝阳区'],
+    customItem: '全部'
   };
   components = {};
   computed = {
@@ -559,6 +583,16 @@ export default class Questions extends wepy.page {
   mixins = [baseMixin];
 
   methods = {
+    bindRegionChange(e){
+      // this.region = e.detail.value
+      let ds = e.currentTarget.dataset;
+      this.info[ds.qid].answer = e.detail.value.join('$$$');
+      this.info[ds.qid].region = e.detail.value||this.region;
+      this.$apply();
+    },
+    propagation(){
+      // console.log('fdsfds')
+    },
     start() {
       this.step = 1;
     },
@@ -567,10 +601,10 @@ export default class Questions extends wepy.page {
         this.page_number--;
         this.$apply();
         this.getQuestions();
-        if(e.currentTarget.dataset.id == "infos"){
+        if (e.currentTarget.dataset.id == 'infos') {
           this.step = 1;
         }
-      }else{
+      } else {
         this.step = 0;
       }
     },
@@ -578,26 +612,49 @@ export default class Questions extends wepy.page {
       let self = this;
       let survey_ids = [];
       let survey_answers = [];
+      let valid = [];
       Object.values(this.info).forEach(info => {
         let answers = [];
         survey_ids.push(info.id);
         if (info.type == 12 || info.type == 13) {
           info.content.forEach((ans, index) => {
             if (ans.checked) {
-              answers.push(index + 1);
+              let answer = index + 1;
+              if(ans.ctype && ans.ctype[0] == 2){
+                answer+= '$$$'+ans.value;
+              }
+              answers.push(answer);
             }
           });
         } else if (info.type == 4) {
           answers = info.imgs;
+        }else if(info.type == 11){
+          answers = info.region;
         } else {
           answers.push(info.answer);
         }
+        if (info.must == 1 && !answers.join(',')) {
+          valid.push(info);
+        }
         survey_answers.push(answers.join(','));
       });
 
+      // console.log(survey_ids.join('||'),survey_answers.join('||'))
+
+      if (valid.length) {
+        wx.showModal({
+          title: '提示',
+          content: '您有未回答的题目',
+          showCancel: false,
+          success: function(res) {}
+        });
+        return;
+      }
+
       self.request('/service/?l=api.survey_submit', {
         data: {
           product_id: this.product.id,
+          order_id: this.order_id,
           page_number: this.user.page,
           survey_id: survey_ids.join('||'),
           survey_answer: survey_answers.join('||')
@@ -605,20 +662,20 @@ export default class Questions extends wepy.page {
         success: function(d) {
           let data = d.data;
           if (data.status == 1) {
-            if (self.page_number < self.user.page_total-1) {
+            if (self.page_number < self.user.page_total - 1) {
               self.page_number++;
               self.$apply();
               // console.log(self.page_number)
               self.getQuestions();
-            }else if(self.page_number ==  self.user.page_total-1){
+            } else if (self.page_number == self.user.page_total - 1) {
               self.step = 2;
               self.page_number = self.user.page_total;
               self.$apply();
               self.getQuestions();
-            }else{
-              wx.navigateTo({
-                url : '/pages/myserve'
-              })
+            } else {
+              wx.switchTab({
+                url: '/pages/myserve'
+              });
             }
           }
         }
@@ -635,10 +692,22 @@ export default class Questions extends wepy.page {
       } else {
         this.info[ds.qid].content[ds.optkey].checked = !checked;
       }
+      this.$apply();
     },
     handleInput(e) {
       let ds = e.currentTarget.dataset;
       this.info[ds.qid].answer = e.detail.value;
+      this.$apply();
+    },
+    inputFocus(e){
+      let ds = e.currentTarget.dataset;
+      this.info[ds.qid].content[ds.optkey].checked = true;
+      this.$apply();
+    },
+    handleOtherInput(e) {
+      let ds = e.currentTarget.dataset;
+      // console.log(e.detail)
+      this.info[ds.qid].content[ds.optkey].value = e.detail.value
     },
     handleFile(e) {
       let self = this;
@@ -667,30 +736,47 @@ export default class Questions extends wepy.page {
     }
   };
 
-  getQuestions() {
+  getQuestions(init) {
     let self = this;
+    let params = {
+      product_id: this.product_id,
+        order_id: this.order_id
+    };
+    if(!init){
+      params.page_number = this.page_number
+    }
     self.request('/service/?l=api.survey', {
-      data: {
-        product_id: this.product_id,
-        page_number: this.page_number
-      },
+      data: params,
       success: function(d) {
         let data = d.data.data;
         self.product = data.product;
         for (let key in data.info) {
           let info = data.info[key];
           if (info.type == 12 || info.type == 13) {
-            let answers = info.answer.split(',');
-            info.content.map((ans, index) => {
-              if (answers.includes('' + (index + 1))) {
-                ans.checked = true;
+            let answers = info.answer?info.answer.split(','):[];
+            answers.forEach(item =>{
+              if(item){
+                let _item = item.split('$$$');
+                info.content[_item[0]-1].checked = true;
+                info.content[_item[0]-1].value = _item[1];
               }
-              return ans;
-            });
+            })
+            // info.content.map((ans, index) => {
+            //   if (answers.includes('' + (index + 1))) {
+            //     ans.checked = true;
+            //     if(ans.ctype[0] == 2){
+            //       // ans.value = ans.
+            //     }
+            //   }
+            //   return ans;
+            // });
           } else if (info.type == 4) {
-            info.imgs = info.answer.split(',');
+            info.imgs = info.answer ? info.answer.split(',') : [];
+          }else if(info.type == 11){
+            info.region = info.answer?info.answer.split('$$$'):self.region;
           }
         }
+        self.page_number = data.user.index;
         self.info = data.info;
         self.user = data.user;
         self.$apply();
@@ -702,7 +788,8 @@ export default class Questions extends wepy.page {
 
   onLoad(options) {
     this.product_id = options.product_id;
-    this.getQuestions();
+    this.order_id = options.order_id;
+    this.getQuestions(1);
   }
 }
 </script>

+ 9 - 7
src/pages/servedetail.wpy

@@ -73,7 +73,6 @@
             </swiper-item>
         </block>
     </swiper>
-    <!-- <image class="banner" src="http://192.168.11.108/assets/jiazhi/tmp1.jpg" mode="widthFix" /> -->
     <view class="article">
         <view class="h1">
             <text>{{product.name}}</text>
@@ -82,15 +81,16 @@
         <view class="p">
           <rich-text nodes="{{product.content}}" ></rich-text>
         </view>
-        <!-- <image class="banner" wx:for="{{product.pics}}" src="{{item}}" mode="widthFix" /> -->
     </view>
     <view class="bbar">
         <view class="btns">
             <view class="btn primary" wx:if="{{product.type1}}" @tap="doExchange" data-id="{{product.id}}">免费兑换</view>
-            <view class="btn" @tap="pay" wx:if="{{product.type2}}" data-id="{{product.id}}" data-cash="{{product.price}}">购买</view>
+            <view class="btn" @tap="handlePay" wx:if="{{product.type2}}" data-id="{{product.id}}" data-cash="{{product.price}}">购买</view>
         </view>
     </view>
     <exchange></exchange>
+    <login></login>
+    <phoneNumber></phoneNumber>
   </view>
 </template>
 
@@ -98,6 +98,8 @@
 import wepy from 'wepy';
 import Exchange from '../components/exchange';
 import baseMixin from '../mixins/base';
+import Login from '../components/login';
+import PhoneNumber from '../components/phoneNumber';
 
 export default class ServeDetail extends wepy.page {
   config = {
@@ -109,7 +111,9 @@ export default class ServeDetail extends wepy.page {
     product: {}
   };
   components = {
-    exchange: Exchange
+    exchange: Exchange,
+    login: Login,
+    phoneNumber:PhoneNumber
   };
   computed = {
     now() {
@@ -120,9 +124,7 @@ export default class ServeDetail extends wepy.page {
   mixins = [baseMixin];
 
   methods = {
-    doExchange(e) {
-      this.$invoke('exchange', 'show', e.currentTarget.dataset.id);
-    }
+    
   };
 
   events = {

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません