details.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. dropDownList: false,
  13. methodsList: ['上游', '下游', '双向合作'],
  14. showType: '',
  15. seIndex: null, //合作方式
  16. throttle: true, //截流
  17. fisadministrator: null,
  18. isCancel: false, //是否取消合作
  19. },
  20. /* 遮罩层点击关闭 */
  21. closeTheDropDown() {
  22. this.setData({
  23. dropDownList: false
  24. })
  25. },
  26. /**
  27. * 生命周期函数--监听页面加载
  28. */
  29. onLoad: function (options) {
  30. const data = JSON.parse(options.data)
  31. let showType = '';
  32. switch (data.ftype) {
  33. case 1:
  34. showType = '上游';
  35. break;
  36. case 2:
  37. showType = '下游';
  38. break;
  39. case 3:
  40. showType = '双向合作';
  41. break;
  42. };
  43. this.setData({
  44. partnerDetails: data,
  45. showType,
  46. seIndex: data.ftype,
  47. fisadministrator: (wx.getStorageSync('userData').fisadministrator == 1) ? false : true,
  48. })
  49. },
  50. /* 选择合作方式 */
  51. modeSelect(e) {
  52. const {
  53. name
  54. } = e.target.dataset, {
  55. index
  56. } = e.target.dataset,
  57. that = this;
  58. wx.showModal({
  59. title: "提示",
  60. content: "是否更改与“" + this.data.partnerDetails.fbrand + "”合作方式为" + name,
  61. success(res) {
  62. if (res.confirm) {
  63. that.setData({
  64. showType: name,
  65. seIndex: index + 1
  66. })
  67. }
  68. that.closeTheDropDown();
  69. }
  70. })
  71. },
  72. /* 下拉 */
  73. dropDown() {
  74. if (this.data.fisadministrator) return wx.showToast({
  75. title: '当前账号无权限操作',
  76. icon: "none"
  77. });
  78. this.setData({
  79. dropDownList: true
  80. })
  81. },
  82. /* 开关 */
  83. onChange({
  84. detail
  85. }) {
  86. const that = this;
  87. if (this.data.fisadministrator) return wx.showToast({
  88. title: '当前账号无权限操作',
  89. icon: "none"
  90. });
  91. this.closeTheDropDown()
  92. if (this.data.checked) {
  93. wx.showModal({
  94. title: "提示",
  95. content: '是否确定取消与“' + this.data.partnerDetails.fbrand + '”的合作关系',
  96. success: function (res) {
  97. if (res.confirm) {
  98. that.setData({
  99. checked: detail,
  100. isCancel: true
  101. });
  102. }
  103. }
  104. })
  105. } else {
  106. that.setData({
  107. checked: detail,
  108. isCancel: false
  109. });
  110. }
  111. },
  112. /* 预览合作商logo */
  113. previewImg() {
  114. const urls = [this.data.partnerDetails.attinfos[0].fobsurl]
  115. this.closeTheDropDown()
  116. wx.previewImage({
  117. current: 1, // 当前显示图片的http链接
  118. urls: urls
  119. })
  120. },
  121. /* 提交 */
  122. submit() {
  123. this.closeTheDropDown()
  124. /* 截流 */
  125. if (!this.data.throttle) return;
  126. this.setData({
  127. throttle: false
  128. });
  129. /* 取消合作 */
  130. if (this.data.isCancel) return _Http.basic({
  131. "accesstoken": wx.getStorageSync('userData').token,
  132. "classname": "customer.tagents.tagents",
  133. "method": "delete_cooperation",
  134. "content": {
  135. "tcooperationagentsid": this.data.partnerDetails.tcooperationagentsid
  136. }
  137. }).then(res => {
  138. if (res.msg != '成功') return wx.showToast({
  139. title: res.data,
  140. icon: "error"
  141. })
  142. setTimeout(() => {
  143. wx.navigateBack({
  144. delta: 1,
  145. })
  146. }, 500);
  147. })
  148. /* 发送修改请求 */
  149. if (this.data.seIndex != this.data.partnerDetails.ftype) {
  150. _Http.basic({
  151. "accesstoken": wx.getStorageSync('userData').token,
  152. "classname": "customer.tagents.tagents",
  153. "method": "update_cooperation",
  154. "content": {
  155. "tcooperationagentsid": this.data.partnerDetails.tcooperationagentsid,
  156. "ftype": this.data.seIndex
  157. }
  158. }).then(res => {
  159. if (res.msg != '成功') return wx.showToast({
  160. title: res.data,
  161. icon: "none"
  162. });
  163. wx.showToast({
  164. title: '修改成功'
  165. });
  166. setTimeout(() => {
  167. wx.navigateBack({
  168. delta: 1,
  169. })
  170. }, 500);
  171. });
  172. } else {
  173. wx.showToast({
  174. title: '保存成功'
  175. });
  176. setTimeout(() => {
  177. wx.navigateBack({
  178. delta: 1,
  179. })
  180. }, 500);
  181. }
  182. },
  183. /**
  184. * 生命周期函数--监听页面初次渲染完成
  185. */
  186. onReady: function () {
  187. },
  188. /**
  189. * 生命周期函数--监听页面显示
  190. */
  191. onShow: function () {
  192. },
  193. /**
  194. * 生命周期函数--监听页面隐藏
  195. */
  196. onHide: function () {
  197. },
  198. /**
  199. * 生命周期函数--监听页面卸载
  200. */
  201. onUnload: function () {
  202. },
  203. /**
  204. * 页面相关事件处理函数--监听用户下拉动作
  205. */
  206. onPullDownRefresh: function () {
  207. },
  208. /**
  209. * 页面上拉触底事件的处理函数
  210. */
  211. onReachBottom: function () {
  212. },
  213. /**
  214. * 用户点击右上角分享
  215. */
  216. onShareAppMessage: function () {
  217. }
  218. })