details.js 5.3 KB

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