123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- const util = require('../../utils/util.js');
- const app = getApp();
- Component({
- properties: {
- show: {
- type: Boolean,
- observer: function (newVal, oldVal) {
- this.setData({ show: newVal })
- }
- },
- options: {
- type: Object,
- observer: function (newVal, oldVal) {
- if (!util.isObjEmpty(newVal)){
- this.setData({ aid: newVal.aid, orderid: newVal.orderid, sname: newVal.sname, title: newVal.title });
- }
- }
- }
- },
- data: {
- imgUrl: [],
- uploadImg: [],
- star: 0,
- aid: '',
- title: '',
- sname:'',
- orderid: '',
- type: '',
- act: '',
- content: '',//评价
- cid: '',
- one: [{ txt: '带队技能欠佳', cet: false }, { txt: '与宣传有差距', cet: false }, { txt: '活动不合理', cet: false }, { txt: '孩子体验一般', cet: false }, { txt: '吃住有待升级', cet: false }, { txt: '性价比一般', cet: false }],
- two: [{ txt: '正能量的小黄人', cet: false }, { txt: '领队专业细心', cet: false }, { txt: '教育意义明显', cet: false }, { txt: '活动安排有序', cet: false }, { txt: '安全措施到位', cet: false }, { txt: '性价比超值', cet: false }],
- chooseIndex: [],
- option: [],
- show:false,//是否显示
- detailStatus: false,//详情是否出现
- recommendArr:[1,2,3,4,5,6,7,8,9,10],//推荐值数组
- recomLevel:0,//推荐值
- inputFocus:false
- },
- methods: {
- chooseImg() {
- let that = this, count = 8, uploadImg = that.data.uploadImg,arr=[];
- that.triggerEvent('selectImage', { isGet: false });
- wx.chooseImage({
- count: count,
- sizeType: ['compressed'],
- sourceType: ['album', 'camera'],
- success: function (res) {
- var imgUrl = res.tempFilePaths;
- if ((imgUrl.length + that.data.uploadImg.length) > count) {
- util.showTips("最多只能上传" + count + "张照片");
- return false;
- }
- wx.showLoading({ title: "上传中" });
- for (let i in imgUrl) {
- wx.uploadFile({
- url: util.config.apiServer + 'user/upload_img_app.do',
- filePath: imgUrl[i],
- name: 'avatarFile',
- formData: {
- "rid": app.globalData.userInfo['rid']
- },
- success: function (reason) {
- let datas = JSON.parse(reason.data);
- if (reason.statusCode==200&&datas.code == 0) {
- arr.push(datas.data.image);
- uploadImg.push(datas.data.image)
- if (arr.length == imgUrl.length) {
- that.setData({ uploadImg });
- wx.hideLoading();
- that.triggerEvent('selectImage', { isGet: true });
- }
- }
- }
- })
- }
- }
- })
- },
- delImg(e) {
- let index = e.currentTarget.dataset.index, uploadImg = this.data.uploadImg;
- uploadImg.splice(index, 1);
- this.setData({ uploadImg })
- },
- submit() {
- var that = this,
- data = {},
- uploadImg = this.data.uploadImg,
- act = this.data.act,
- userInfo = app.globalData.userInfo,
- star = this.data.star,
- content = this.data.content,
- option = this.data.two;
- if (star == 1 || star == 2) {
- option = this.data.one;
- }
- for (let i in option) {
- if (option[i].cet) {
- content = content + '#' + option[i].txt + '#'
- }
- }
- data['aid'] = this.data.aid;
- data['orderid'] = this.data.orderid;//订单id
- data['arating'] = star;//活动评分
- data['leaderrating'] = '5';//领队评分
- data['content'] = content;
- data['cid'] = this.data.cid;
- data['image'] = uploadImg ? uploadImg.join(',') : '';
- data['rid'] = userInfo ? userInfo['rid'] : "";
- data['recomLevel'] = this.data.recomLevel;
- if (this.data.recomLevel==0) {
- util.showTips("请选择推荐值");
- return false;
- }
- if (util.isEmpty(data.content)) {
- util.showTips("请填写评分原因");
- return false;
- }
- util.ajax({
- func: "v2/comments/order/addcomment",
- data: data,
- method: "POST",
- load:true,
- title:'提交中'
- }, function (res) {
- wx.hideLoading();
- if (res.code == 0) {
- wx.redirectTo({
- url: '/pages/order/scratch/scratch?orderid=' + that.data.orderid+'&coin='+res.data||0
- })
- } else {
- util.showTips(res.reason);
- }
- });
- },
- chooseOpt: function (e) {
- var star = this.data.star, chooseIndex = this.data.chooseIndex, index = e.currentTarget.dataset.index, option = this.data.two;
- if (star == 1 || star == 2) {
- option = this.data.one;
- }
- if (option[index].cet) {
- option[index].cet = false;
- } else {
- option[index].cet = true;
- }
- if (star == 1 || star == 2) {
- this.setData({ one: option });
- } else {
- this.setData({ two: option });
- }
- },
- bindblur: function (e) {
- this.setData({ content: e.detail.value, inputFocus: false });
- },
- bindinput(e){
- this.setData({ content: e.detail.value});
- },
- bindstar: function (e) {
- this.setData({ star: e.target.dataset.index,detailStatus:true });
- },
- bindfocus(e){
- this.setData({inputFocus:true})
- },
- recommend(e){
- this.setData({ recomLevel: e.target.dataset.number})
- },
- close(){
- this.triggerEvent('myevent', {}, {});
- }
- }
- })
|