applyFor.js 7.6 KB

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