comment.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. var _request = require('../../../../utils/request.js')
  2. var rid;
  3. var pid;
  4. Page({
  5. data: {
  6. order: {},
  7. express: '',
  8. total:0,
  9. lvList:[
  10.     '/images/star_a_l.png',
  11.     '/images/star_a_r.png',
  12.     '/images/star_a_l.png',
  13.     '/images/star_a_r.png',
  14. '/images/star_a_l.png',
  15.     '/images/star_a_r.png',
  16. '/images/star_a_l.png',
  17.     '/images/star_a_r.png',
  18. '/images/star_a_l.png',
  19.     '/images/star_a_r.png'
  20.   ],//星星个数
  21.   lvListActive1: '/images/star_a_l.png',//选中的
  22.   lvListActive2:'/images/star_d_l.png',//未选中的
  23. lvListActive3: '/images/star_a_r.png',//选中的
  24.   lvListActive4:'/images/star_d_r.png',//未选中的
  25. star_txt:'非常好',
  26. commtxt:'商品不错,物流快,好评',
  27. commlv:9
  28. },
  29. onLoad: function (options) {
  30. rid = options.id;
  31. pid = options.pid;
  32. this.getProjectDetail()
  33. },
  34. getProjectDetail () {
  35. var that = this
  36. var url = "v1/product/" + pid;
  37. var params = {}
  38. var success = function (val) {
  39. console.log('data',val.data)
  40. that.setData({
  41. order: val.data,
  42. });
  43. }
  44. _request.$get(url, params, success)
  45. },
  46. confirmPopup () {
  47. var that = this
  48. wx.showModal({
  49. title: '提示',
  50. content: '是否确认收货?',
  51. success: function(res) {
  52. if (res.confirm) {
  53. that.confirmOrder()
  54. } else if (res.cancel) {
  55. }
  56. }
  57. })
  58. },
  59. CancelPopup () {
  60. var that = this
  61. wx.showModal({
  62. title: '提示',
  63. content: '确定取消该订单?',
  64. success: function(res) {
  65. if (res.confirm) {
  66. that.CancelOrder()
  67. } else if (res.cancel) {
  68. }
  69. }
  70. })
  71. },
  72. confirmOrder: function () {
  73. var id = this.data.order.order_id
  74. var that = this
  75. var url = 'v1/order/' + id + '/confirm'
  76. var params = {
  77. }
  78. var success = function (res) {
  79. getApp().globalData.order = true
  80. wx.navigateBack()
  81. }
  82. _request.$put(url, params, success)
  83. },
  84. CancelOrder: function () {
  85. var id = this.data.order.order_id
  86. var that = this
  87. var url = 'v1/order/' + id + '/cancel'
  88. var params = {
  89. }
  90. var success = function (res) {
  91. getApp().globalData.order = true
  92. wx.navigateBack()
  93. }
  94. _request.$put(url, params, success)
  95. },
  96. formatOrder: function () {
  97. var id = this.data.order.express_order_no
  98. var result = ''
  99. for (var i = 0; i < id.length; i++) {
  100. if (i%4 === 0 && i !== 0) {
  101. result = result + ' '
  102. }
  103. result = result + id[i]
  104. }
  105. this.setData({
  106. express: result
  107. })
  108. },
  109. copeOrder: function () {
  110. var that = this
  111. var id = this.data.order.express_order_no
  112. wx.setClipboardData({
  113. data: id,
  114. success: function(res) {
  115. wx.showToast({
  116. title: '已成功复制到剪贴板',
  117. icon: 'none',
  118. duration: 2000
  119. })
  120. }
  121. })
  122. },
  123. onShareAppMessage: function (val) {
  124. return _request.share({
  125. sc: 'xcx_user_order'
  126. })
  127. },
  128. evaluateLv(e){
  129. console.log(e);
  130. var that = this;
  131. var idx = e.currentTarget.dataset.index;
  132. var lvList = that.data.lvList;
  133. console.log('idx',idx);
  134. var star_txt = '';
  135. if(idx == 9) star_txt = '非常好';
  136. if(idx == 8) star_txt = '满意';
  137. if(idx == 7) star_txt = '满意';
  138. if(idx == 6) star_txt = '一般';
  139. if(idx == 5) star_txt = '一般';
  140. if(idx == 4) star_txt = '差';
  141. if(idx == 3) star_txt = '差';
  142. if(idx == 2) star_txt = '非常差';
  143. if(idx == 1) star_txt = '非常差';
  144. if(idx == 0) star_txt = '非常差';
  145. lvList.forEach((item,index) => {
  146. console.log('index',index);
  147. if(index <= idx){
  148. if(index % 2 === 0){
  149. lvList[index] = that.data.lvListActive1;
  150. }else{
  151. lvList[index] = that.data.lvListActive3;
  152. }
  153. }else{
  154. if(index % 2 === 0){
  155. lvList[index] = that.data.lvListActive2;
  156. }else{
  157. lvList[index] = that.data.lvListActive4;
  158. }
  159.     }
  160.   })
  161. that.setData({
  162. lvList: lvList,
  163. star_txt:star_txt,
  164. commlv:idx
  165. })
  166. },
  167. bindcomm: function (e) {
  168. this.setData({
  169. commtxt: e.detail.value
  170. })
  171. },
  172. sendComment() {
  173. var that = this
  174. var url = 'v1/order_detail/'+ rid +'/commend';
  175. var score = (this.data.commlv + 1) * 10 /2;
  176. var params = {
  177. detail:this.data.commtxt,
  178. score:score
  179. }
  180. var success = function (res) {
  181. wx.showToast({
  182. title: '申请添加评论成功',
  183. icon: 'none',
  184. duration: 2000
  185. })
  186. wx.navigateBack({ changed: true });
  187. }
  188. _request.$put(url, params, success)
  189. },
  190. })