giftview.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. const app = getApp();
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. item: [],
  8. active: 0,
  9. is_fusion: 0,
  10. item_checkbox:0,
  11. checkbox: [] ,
  12. service:0,
  13. steps: [
  14. {text: '待付款'},
  15. {text: '待确认'},
  16. {text: '待发货'},
  17. {text: '已发货'}
  18. ],
  19. order_no: null,
  20. },
  21. /**
  22. * 生命周期函数--监听页面加载 */
  23. onLoad: function (options) {
  24. let order_no = options.order_no;
  25. this.setData({
  26. order_no: order_no,
  27. gift_1:false,
  28. })
  29. this.getOrder(order_no);
  30. },
  31. /**
  32. * 读取订单信息
  33. */
  34. getOrder: function (order_no) {
  35. let that = this, checkbox = that.data.checkbox;
  36. app.api().Get("api/v3/fastshop/order/review", { order_no: order_no }, function (rel) {
  37. var item = rel.data;
  38. var active = 0;
  39. if (item['status'] == 0) {
  40. if (item['paid_at'] == 0) {
  41. active = 0;
  42. } else {
  43. if (item['is_entrust'] == 0) {
  44. active = 1;
  45. } else {
  46. if (item['express_status'] == 0) {
  47. active = 2;
  48. } else {
  49. active = 3;
  50. }
  51. }
  52. }
  53. } else {
  54. active = 3;
  55. }
  56. //多选
  57. for (let n in item.gift) {
  58. checkbox[n] = 0;
  59. }
  60. that.setData({
  61. item: rel.data,
  62. active: active,
  63. checkbox: checkbox,
  64. })
  65. })
  66. },
  67. /**
  68. * 确认委托出售
  69. */
  70. onClickGift: function (e) {
  71. let that = this;
  72. var service = that.data.service;
  73. if (service == false){
  74. wx.showModal({
  75. content: '您必须遵守平台用户服务协议',
  76. showCancel: false,
  77. });
  78. }else{
  79. wx.showModal({
  80. content: '确定把已选产品卖了换钱?',
  81. success: function (res) {
  82. if (res.confirm) {
  83. var param = {
  84. order_no: that.data.order_no,
  85. service: service,
  86. gift: JSON.stringify(that.data.checkbox),
  87. item_checkbox: that.data.item_checkbox
  88. }
  89. app.api().Post("api/v3/fastshop/order/giftAction",param,function (rel) {
  90. wx.showModal({
  91. content: rel.msg,
  92. showCancel: false,
  93. success: function () {
  94. wx.navigateBack({
  95. delta:1
  96. })
  97. }
  98. })
  99. })
  100. }
  101. }
  102. })
  103. }
  104. },
  105. /*确认签收 */
  106. okOrder: function (event) {
  107. let that = this;
  108. var onderNo = that.data.order_no;
  109. wx.showModal({
  110. content: '您确认收到了吗?',
  111. success: function (res) {
  112. if (res.confirm) {
  113. app.api().Post("api/v3/fastshop/order/signorder", { order_no: onderNo }, function (rel) {
  114. wx.showModal({
  115. title: '友情提示',
  116. content: rel.msg,
  117. showCancel: false,
  118. success: function () {
  119. that.getOrder(onderNo);
  120. that.setData({
  121. active: 3,
  122. })
  123. }
  124. })
  125. })
  126. }
  127. }
  128. })
  129. },
  130. /**
  131. * 选择主商品
  132. */
  133. onChangeItem(event) {
  134. this.setData({
  135. item_checkbox: this.data.item_checkbox?0:1
  136. })
  137. },
  138. /**
  139. * 选择赠品
  140. */
  141. onChange(event) {
  142. var key = event.currentTarget.dataset.key, checkbox = this.data.checkbox;
  143. for (let i in checkbox) {
  144. checkbox[key] = event.detail?1:0
  145. }
  146. this.setData({
  147. checkbox: checkbox
  148. })
  149. },
  150. /**
  151. * 是否选择用户服务协议
  152. */
  153. onService(event) {
  154. this.setData({
  155. service: event.detail?1:0
  156. });
  157. },
  158. /**查询快递 */
  159. getMaps: function (event) {
  160. var onderNo = this.data.order_no;
  161. let config = app.globalData.wechat_config;
  162. wx.navigateTo({
  163. url: '/pages/helper/webview?src=' + app.api_root + '/api-' + config.app_id + '/v3/fastshop/webview/express&ids=' + onderNo,
  164. })
  165. },
  166. /**
  167. * 服务协议
  168. */
  169. service() {
  170. let config = app.globalData.wechat_config;
  171. wx.navigateTo({
  172. url: '/pages/helper/webview?src=' + app.api_root + '/api-' + config.app_id + '/v3/fastshop/webview/service'
  173. })
  174. }
  175. })