details.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. import {
  2. ApiModel
  3. } from "../../utils/api";
  4. const _Http = new ApiModel;
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. checked: true, //开关
  11. partnerDetails: {}, //合作详情
  12. seIndex: null, //合作方式
  13. throttle: true, //截流
  14. fisadministrator: null,
  15. isCancel: false, //是否取消合作
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad: function (options) {
  21. const data = JSON.parse(options.data)
  22. this.setData({
  23. partnerDetails: data,
  24. seIndex: data.ftype,
  25. fisadministrator: (wx.getStorageSync('userData').fisadministrator == 1) ? false : true,
  26. })
  27. },
  28. /* 开关 */
  29. onChange({
  30. detail
  31. }) {
  32. const that = this;
  33. if (this.data.fisadministrator) return wx.showToast({
  34. title: '当前账号无权限操作',
  35. icon: "none"
  36. });
  37. if (this.data.checked) {
  38. wx.showModal({
  39. title: "提示",
  40. content: '是否确定取消与“' + this.data.partnerDetails.fbrand + '”的合作关系',
  41. success: function (res) {
  42. if (res.confirm) {
  43. that.setData({
  44. checked: detail,
  45. isCancel: true
  46. });
  47. }
  48. }
  49. })
  50. } else {
  51. that.setData({
  52. checked: detail,
  53. isCancel: false
  54. });
  55. }
  56. },
  57. /* 预览合作商logo */
  58. previewImg() {
  59. const urls = [this.data.partnerDetails.attinfos[0].fobsurl]
  60. wx.previewImage({
  61. current: 1, // 当前显示图片的http链接
  62. urls: urls
  63. })
  64. },
  65. /* 提交 */
  66. submit() {
  67. /* 截流 */
  68. if (!this.data.throttle) return;
  69. this.setData({
  70. throttle: false
  71. });
  72. /* 取消合作 */
  73. if (this.data.isCancel) return _Http.basic({
  74. "accesstoken": wx.getStorageSync('userData').token,
  75. "classname": "customer.tagents.tagents",
  76. "method": "delete_cooperation",
  77. "content": {
  78. "tcooperationagentsid": this.data.partnerDetails.tcooperationagentsid
  79. }
  80. }).then(res => {
  81. if (res.msg != '成功') return wx.showToast({
  82. title: res.data,
  83. icon: "error"
  84. })
  85. setTimeout(() => {
  86. wx.navigateBack({
  87. delta: 1,
  88. })
  89. }, 500);
  90. })
  91. /* 发送修改请求 */
  92. if (this.data.seIndex != this.data.partnerDetails.ftype) {
  93. _Http.basic({
  94. "accesstoken": wx.getStorageSync('userData').token,
  95. "classname": "customer.tagents.tagents",
  96. "method": "update_cooperation",
  97. "content": {
  98. "tcooperationagentsid": this.data.partnerDetails.tcooperationagentsid,
  99. "ftype": this.data.seIndex
  100. }
  101. }).then(res => {
  102. if (res.msg != '成功') return wx.showToast({
  103. title: res.data,
  104. icon: "none"
  105. });
  106. wx.showToast({
  107. title: '修改成功'
  108. });
  109. setTimeout(() => {
  110. wx.navigateBack({
  111. delta: 1,
  112. })
  113. }, 500);
  114. });
  115. } else {
  116. wx.showToast({
  117. title: '保存成功'
  118. });
  119. setTimeout(() => {
  120. wx.navigateBack({
  121. delta: 1,
  122. })
  123. }, 500);
  124. }
  125. },
  126. /**
  127. * 生命周期函数--监听页面初次渲染完成
  128. */
  129. onReady: function () {
  130. },
  131. /**
  132. * 生命周期函数--监听页面显示
  133. */
  134. onShow: function () {
  135. },
  136. /**
  137. * 生命周期函数--监听页面隐藏
  138. */
  139. onHide: function () {
  140. },
  141. /**
  142. * 生命周期函数--监听页面卸载
  143. */
  144. onUnload: function () {
  145. },
  146. /**
  147. * 页面相关事件处理函数--监听用户下拉动作
  148. */
  149. onPullDownRefresh: function () {
  150. },
  151. /**
  152. * 页面上拉触底事件的处理函数
  153. */
  154. onReachBottom: function () {
  155. },
  156. /**
  157. * 用户点击右上角分享
  158. */
  159. onShareAppMessage: function () {
  160. }
  161. })