applyFor.js 7.4 KB

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