applyFor.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. import {
  2. ApiModel
  3. } from "../../utils/api";
  4. const _Http = new ApiModel;
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. requestList: [], //请求列表
  11. showBtn: -1, //选中下标
  12. pattern: false, //显示方式选择
  13. dropDownList: false, //显示下拉菜单
  14. methodsList: ['上游', '下游', '双向合作'],
  15. addvalue: ""
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad: function (options) {
  21. _Http.basic({
  22. "accesstoken": wx.getStorageSync('userData').token,
  23. "classname": "customer.tagents.tagents",
  24. "method": "query_cooperation",
  25. "content": {
  26. "getdatafromdbanyway": true,
  27. "pageNumber": 1,
  28. "pageSize": 20,
  29. "where": {
  30. "condition": "",
  31. "ftype": "",
  32. "fstatus": "申请"
  33. }
  34. }
  35. }).then(res => {
  36. console.log(res)
  37. if (res.msg != "成功") return wx.showToast({
  38. title: res.data,
  39. icon: 'none'
  40. })
  41. this.setData({
  42. requestList: res.data
  43. })
  44. })
  45. },
  46. onChange({
  47. detail
  48. }) {
  49. this.setData({
  50. addvalue: detail
  51. })
  52. },
  53. onClick() {
  54. _Http.basic({
  55. "accesstoken": wx.getStorageSync('userData').token,
  56. "classname": "customer.tagents.tagents",
  57. "method": "apply_cooperation",
  58. "content": {
  59. "tcooperationagentsid": "27303",
  60. "ftype": "1"
  61. }
  62. }).then(res => {
  63. console.log(res)
  64. })
  65. },
  66. /**
  67. * 生命周期函数--监听页面初次渲染完成
  68. */
  69. onReady: function () {
  70. },
  71. modeSelect(e) {
  72. const {
  73. index
  74. } = e.target.dataset,
  75. i = this.data.showBtn,
  76. that = this;
  77. const content = (this.data.methodsList[index] == '双向合作') ? '是否确定将“' + this.data.requestList[i].fagentname + '”作为您的“' + this.data.methodsList[index] + '”伙伴' : '是否确定将“' + this.data.requestList[i].fagentname + '”作为您的“' + this.data.methodsList[index] + '合作”伙伴';
  78. let ftype = Number;
  79. switch (this.data.methodsList[index]) {
  80. case "上游":
  81. ftype = 1;
  82. break;
  83. case "下游":
  84. ftype = 2;
  85. break;
  86. case "双向合作":
  87. ftype = 3;
  88. break;
  89. }
  90. wx.showModal({
  91. title: '提示',
  92. content: content,
  93. success: function (res) {
  94. if (res.confirm) {
  95. _Http.basic({
  96. "accesstoken": wx.getStorageSync('userData').token,
  97. "classname": "customer.tagents.tagents",
  98. "method": "cooperation",
  99. "content": {
  100. "tcooperationagentsid": that.data.requestList[i].tcooperationagentsid,
  101. "ftype": ftype
  102. }
  103. }).then(res => {
  104. if (res.msg != '成功') return wx.showToast({
  105. title: res.data,
  106. icon: "none"
  107. });
  108. wx.showToast({
  109. title: '合作成功!',
  110. })
  111. let requestList = that.data.requestList;
  112. requestList.splice(i, 1);
  113. that.setData({
  114. requestList
  115. })
  116. })
  117. } else {
  118. console.log('取消')
  119. }
  120. }
  121. })
  122. },
  123. /* 选择 */
  124. showBtnIndex(e) {
  125. const {
  126. index
  127. } = e.currentTarget.dataset;
  128. if (index == this.data.showBtn) return;
  129. this.setData({
  130. pattern: false,
  131. showBtn: index,
  132. })
  133. },
  134. /* 选择合作方式 */
  135. chooseCooperationMode() {
  136. this.setData({
  137. dropDownList: !this.data.dropDownList
  138. })
  139. },
  140. hiddenDropDown() {
  141. this.setData({
  142. dropDownList: false
  143. })
  144. },
  145. /* 同意 */
  146. ratify(e) {
  147. this.setData({
  148. pattern: true
  149. })
  150. },
  151. /* 拒绝 */
  152. refuse(e) {
  153. const {
  154. index
  155. } = e.currentTarget.dataset,
  156. that = this;
  157. wx.showModal({
  158. title: "提示",
  159. content: '是否确定拒绝“' + this.data.requestList[index].fbrand + '”的合作请求',
  160. success(res) {
  161. if (res.confirm) {
  162. _Http.basic({
  163. "accesstoken": wx.getStorageSync('userData').token,
  164. "classname": "customer.tagents.tagents",
  165. "method": "delete_cooperation",
  166. "content": {
  167. "tcooperationagentsid": that.data.requestList[index].tcooperationagentsid
  168. }
  169. }).then(res => {
  170. console.log(res)
  171. if (res.msg != '成功') return wx.showToast({
  172. title: res.data,
  173. icon: "none"
  174. });
  175. let requestList = that.data.requestList;
  176. requestList.splice(index, 1)
  177. that.setData({
  178. requestList
  179. })
  180. })
  181. }
  182. }
  183. })
  184. },
  185. /**
  186. * 生命周期函数--监听页面显示
  187. */
  188. onShow: function () {
  189. },
  190. /**
  191. * 生命周期函数--监听页面隐藏
  192. */
  193. onHide: function () {
  194. },
  195. /**
  196. * 生命周期函数--监听页面卸载
  197. */
  198. onUnload: function () {
  199. },
  200. /**
  201. * 页面相关事件处理函数--监听用户下拉动作
  202. */
  203. onPullDownRefresh: function () {
  204. },
  205. /**
  206. * 页面上拉触底事件的处理函数
  207. */
  208. onReachBottom: function () {
  209. },
  210. /**
  211. * 用户点击右上角分享
  212. */
  213. onShareAppMessage: function () {
  214. }
  215. })