details.js 5.8 KB

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