|
@@ -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>
|