nps.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. const util = require('../../utils/util.js');
  2. const app = getApp();
  3. Component({
  4. properties: {
  5. show: {
  6. type: Boolean,
  7. observer: function (newVal, oldVal) {
  8. this.setData({ show: newVal })
  9. }
  10. },
  11. options: {
  12. type: Object,
  13. observer: function (newVal, oldVal) {
  14. if (!util.isObjEmpty(newVal)){
  15. this.setData({ aid: newVal.aid, orderid: newVal.orderid, sname: newVal.sname, title: newVal.title });
  16. }
  17. }
  18. }
  19. },
  20. data: {
  21. imgUrl: [],
  22. uploadImg: [],
  23. star: 0,
  24. aid: '',
  25. title: '',
  26. sname:'',
  27. orderid: '',
  28. type: '',
  29. act: '',
  30. content: '',//评价
  31. cid: '',
  32. one: [{ txt: '带队技能欠佳', cet: false }, { txt: '与宣传有差距', cet: false }, { txt: '活动不合理', cet: false }, { txt: '孩子体验一般', cet: false }, { txt: '吃住有待升级', cet: false }, { txt: '性价比一般', cet: false }],
  33. two: [{ txt: '正能量的小黄人', cet: false }, { txt: '领队专业细心', cet: false }, { txt: '教育意义明显', cet: false }, { txt: '活动安排有序', cet: false }, { txt: '安全措施到位', cet: false }, { txt: '性价比超值', cet: false }],
  34. chooseIndex: [],
  35. option: [],
  36. show:false,//是否显示
  37. detailStatus: false,//详情是否出现
  38. recommendArr:[1,2,3,4,5,6,7,8,9,10],//推荐值数组
  39. recomLevel:0,//推荐值
  40. inputFocus:false
  41. },
  42. methods: {
  43. chooseImg() {
  44. let that = this, count = 8, uploadImg = that.data.uploadImg,arr=[];
  45. that.triggerEvent('selectImage', { isGet: false });
  46. wx.chooseImage({
  47. count: count,
  48. sizeType: ['compressed'],
  49. sourceType: ['album', 'camera'],
  50. success: function (res) {
  51. var imgUrl = res.tempFilePaths;
  52. if ((imgUrl.length + that.data.uploadImg.length) > count) {
  53. util.showTips("最多只能上传" + count + "张照片");
  54. return false;
  55. }
  56. wx.showLoading({ title: "上传中" });
  57. for (let i in imgUrl) {
  58. wx.uploadFile({
  59. url: util.config.apiServer + 'user/upload_img_app.do',
  60. filePath: imgUrl[i],
  61. name: 'avatarFile',
  62. formData: {
  63. "rid": app.globalData.userInfo['rid']
  64. },
  65. success: function (reason) {
  66. let datas = JSON.parse(reason.data);
  67. if (reason.statusCode==200&&datas.code == 0) {
  68. arr.push(datas.data.image);
  69. uploadImg.push(datas.data.image)
  70. if (arr.length == imgUrl.length) {
  71. that.setData({ uploadImg });
  72. wx.hideLoading();
  73. that.triggerEvent('selectImage', { isGet: true });
  74. }
  75. }
  76. }
  77. })
  78. }
  79. }
  80. })
  81. },
  82. delImg(e) {
  83. let index = e.currentTarget.dataset.index, uploadImg = this.data.uploadImg;
  84. uploadImg.splice(index, 1);
  85. this.setData({ uploadImg })
  86. },
  87. submit() {
  88. var that = this,
  89. data = {},
  90. uploadImg = this.data.uploadImg,
  91. act = this.data.act,
  92. userInfo = app.globalData.userInfo,
  93. star = this.data.star,
  94. content = this.data.content,
  95. option = this.data.two;
  96. if (star == 1 || star == 2) {
  97. option = this.data.one;
  98. }
  99. for (let i in option) {
  100. if (option[i].cet) {
  101. content = content + '#' + option[i].txt + '#'
  102. }
  103. }
  104. data['aid'] = this.data.aid;
  105. data['orderid'] = this.data.orderid;//订单id
  106. data['arating'] = star;//活动评分
  107. data['leaderrating'] = '5';//领队评分
  108. data['content'] = content;
  109. data['cid'] = this.data.cid;
  110. data['image'] = uploadImg ? uploadImg.join(',') : '';
  111. data['rid'] = userInfo ? userInfo['rid'] : "";
  112. data['recomLevel'] = this.data.recomLevel;
  113. if (this.data.recomLevel==0) {
  114. util.showTips("请选择推荐值");
  115. return false;
  116. }
  117. if (util.isEmpty(data.content)) {
  118. util.showTips("请填写评分原因");
  119. return false;
  120. }
  121. util.ajax({
  122. func: "v2/comments/order/addcomment",
  123. data: data,
  124. method: "POST",
  125. load:true,
  126. title:'提交中'
  127. }, function (res) {
  128. wx.hideLoading();
  129. if (res.code == 0) {
  130. wx.redirectTo({
  131. url: '/pages/order/scratch/scratch?orderid=' + that.data.orderid+'&coin='+res.data||0
  132. })
  133. } else {
  134. util.showTips(res.reason);
  135. }
  136. });
  137. },
  138. chooseOpt: function (e) {
  139. var star = this.data.star, chooseIndex = this.data.chooseIndex, index = e.currentTarget.dataset.index, option = this.data.two;
  140. if (star == 1 || star == 2) {
  141. option = this.data.one;
  142. }
  143. if (option[index].cet) {
  144. option[index].cet = false;
  145. } else {
  146. option[index].cet = true;
  147. }
  148. if (star == 1 || star == 2) {
  149. this.setData({ one: option });
  150. } else {
  151. this.setData({ two: option });
  152. }
  153. },
  154. bindblur: function (e) {
  155. this.setData({ content: e.detail.value, inputFocus: false });
  156. },
  157. bindinput(e){
  158. this.setData({ content: e.detail.value});
  159. },
  160. bindstar: function (e) {
  161. this.setData({ star: e.target.dataset.index,detailStatus:true });
  162. },
  163. bindfocus(e){
  164. this.setData({inputFocus:true})
  165. },
  166. recommend(e){
  167. this.setData({ recomLevel: e.target.dataset.number})
  168. },
  169. close(){
  170. this.triggerEvent('myevent', {}, {});
  171. }
  172. }
  173. })