applyFor.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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. scrolltolowerThrottle: true, //下拉触底截流
  13. pageNumber: 1, //请求分页
  14. pageTotal: 1, //总页数
  15. tabsList: ['建立新合作', '合作请求'], //tabs
  16. tabsIndex: 0, //tabs 选中下标
  17. },
  18. /**
  19. * 生命周期函数--监听页面加载
  20. */
  21. onLoad: function (options) {
  22. /* 判断主副账号 */
  23. if (wx.getStorageSync('userData').fisadministrator == 0) {
  24. this.setData({
  25. tabsList: ['建立新合作']
  26. })
  27. }
  28. this.getList();
  29. },
  30. /* tabs切换页面 */
  31. setIndex({
  32. detail
  33. }) {
  34. this.setData({
  35. tabsIndex: detail
  36. })
  37. },
  38. /* 下拉触底 */
  39. scrolltolower() {
  40. if (!this.data.scrolltolowerThrottle) return;
  41. if (this.data.pageTotal < this.data.pageNumber) return;
  42. this.setData({
  43. scrolltolowerThrottle: false
  44. })
  45. this.getList();
  46. },
  47. /* 获得列表 */
  48. getList() {
  49. _Http.basic({
  50. "accesstoken": wx.getStorageSync('userData').token,
  51. "classname": "customer.tagents.tagents",
  52. "method": "query_cooperation",
  53. "content": {
  54. "getdatafromdbanyway": true,
  55. "pageNumber": this.data.pageNumber,
  56. "pageSize": 20,
  57. "where": {
  58. "condition": "",
  59. "fstatus": "申请"
  60. }
  61. }
  62. }).then(res => {
  63. if (res.msg != "成功") return wx.showToast({
  64. title: res.data,
  65. icon: 'none'
  66. })
  67. let requestList = [];
  68. if (res.pageNumber == 1) {
  69. requestList = res.data
  70. } else {
  71. requestList = this.data.requestList.concat(res.data)
  72. }
  73. this.setData({
  74. requestList,
  75. scrolltolowerThrottle: true,
  76. pageTotal: res.pageTotal,
  77. pageNumber: this.data.pageNumber + 1
  78. })
  79. })
  80. },
  81. /**
  82. * 生命周期函数--监听页面初次渲染完成
  83. */
  84. onReady: function () {
  85. },
  86. /* 选择 */
  87. showBtnIndex(e) {
  88. let {
  89. index
  90. } = e.currentTarget.dataset;
  91. if (index == this.data.showBtn) index = -1;
  92. this.setData({
  93. showBtn: index,
  94. })
  95. },
  96. /* 同意 */
  97. ratify() {
  98. const i = this.data.showBtn,
  99. that = this;
  100. wx.showModal({
  101. title: '提示',
  102. content: "是否同意“" + that.data.requestList[i].fbrand + '”的合作申请',
  103. success: function (res) {
  104. if (res.confirm) {
  105. _Http.basic({
  106. "accesstoken": wx.getStorageSync('userData').token,
  107. "classname": "customer.tagents.tagents",
  108. "method": "cooperation",
  109. "content": {
  110. "tcooperationagentsid": that.data.requestList[i].tcooperationagentsid
  111. }
  112. }).then(res => {
  113. console.log(res)
  114. if (res.msg != '成功') return wx.showToast({
  115. title: res.data,
  116. icon: "none"
  117. });
  118. wx.showToast({
  119. title: '合作成功!',
  120. })
  121. let requestList = that.data.requestList;
  122. requestList.splice(i, 1);
  123. that.setData({
  124. requestList,
  125. showBtn: -1
  126. })
  127. })
  128. }
  129. }
  130. })
  131. },
  132. /* 拒绝 */
  133. refuse(e) {
  134. const {
  135. index
  136. } = e.currentTarget.dataset,
  137. that = this;
  138. wx.showModal({
  139. title: "提示",
  140. content: '是否确定拒绝“' + this.data.requestList[index].fbrand + '”的合作请求',
  141. success(res) {
  142. if (res.confirm) {
  143. _Http.basic({
  144. "accesstoken": wx.getStorageSync('userData').token,
  145. "classname": "customer.tagents.tagents",
  146. "method": "delete_cooperation",
  147. "content": {
  148. "tcooperationagentsid": that.data.requestList[index].tcooperationagentsid
  149. }
  150. }).then(res => {
  151. console.log(res)
  152. if (res.msg != '成功') return wx.showToast({
  153. title: res.data,
  154. icon: "none"
  155. });
  156. let requestList = that.data.requestList;
  157. requestList.splice(index, 1)
  158. that.setData({
  159. requestList
  160. })
  161. })
  162. }
  163. }
  164. })
  165. },
  166. /**
  167. * 生命周期函数--监听页面显示
  168. */
  169. onShow: function () {
  170. },
  171. /**
  172. * 生命周期函数--监听页面隐藏
  173. */
  174. onHide: function () {
  175. },
  176. /**
  177. * 生命周期函数--监听页面卸载
  178. */
  179. onUnload: function () {
  180. },
  181. /**
  182. * 页面相关事件处理函数--监听用户下拉动作
  183. */
  184. onPullDownRefresh: function () {
  185. },
  186. /**
  187. * 页面上拉触底事件的处理函数
  188. */
  189. onReachBottom: function () {
  190. },
  191. /**
  192. * 用户点击右上角分享
  193. */
  194. onShareAppMessage: function () {
  195. }
  196. })