details.js 5.4 KB

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