details.js 5.8 KB

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