applyFor.js 7.7 KB

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