index.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. import {
  2. ApiModel
  3. } from "../../../utils/api";
  4. const _Http = new ApiModel();
  5. const handleList = require("../../../utils/processingData");
  6. const analyze = require("../../../components/My_TwoDimensionalCode/analyze");
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. productList: [], //供需列表
  13. //轮播图列表
  14. swiperBannerList: [],
  15. /* 宫格列表 */
  16. gridList: [{
  17. text: '供需广场',
  18. icon: 'https://bwj.obs.cn-east-2.myhuaweicloud.com/resources/WeChat/home-grid/icon-02.png'
  19. }, {
  20. text: '私域直播',
  21. icon: 'https://bwj.obs.cn-east-2.myhuaweicloud.com/resources/WeChat/home-grid/icon-01.png'
  22. }, {
  23. text: '通告',
  24. icon: 'https://bwj.obs.cn-east-2.myhuaweicloud.com/resources/WeChat/home-grid/icon-01.png'
  25. }],
  26. /* 圆角按钮tabs列表 */
  27. roundedList: ["兴趣爱好", "关注板块", "最新发布"],
  28. partnerList: [], //合作商家列表
  29. codeMsg: {}, //二维码信息
  30. MyModelShow: false, //二维码二次确认
  31. MyModelText: "", //提示框文本
  32. },
  33. /* tabs切换 */
  34. /* tabsSelectedIitem(text) {
  35. console.log(text.detail)
  36. }, */
  37. /* 宫格区跳转 */
  38. gridJumpPage(e) {
  39. const {
  40. name
  41. } = e.target.dataset;
  42. if (name == '供需广场') {
  43. wx.switchTab({
  44. url: '/pages/tabbar-pages/supplyAndDemand/index',
  45. })
  46. } else if (name == '私域直播') {
  47. wx.navigateTo({
  48. url: '/pages/liveStreaming/index',
  49. })
  50. } else if (name == '通告') {
  51. wx.navigateTo({
  52. url: '/pages/annunciate/index',
  53. })
  54. } else {
  55. wx.showToast({
  56. title: '功能开发中',
  57. icon: "none"
  58. })
  59. }
  60. },
  61. /* 获得展示区标题 */
  62. getExhibitionTitle(title) {
  63. const {
  64. detail
  65. } = title;
  66. if (detail == '最新供需') {
  67. wx.switchTab({
  68. url: '/pages/tabbar-pages/supplyAndDemand/index',
  69. })
  70. } else if (detail == '合作商家') {
  71. wx.navigateTo({
  72. url: '/pages/businessPartner/index',
  73. })
  74. }
  75. },
  76. /**
  77. * 生命周期函数--监听页面加载
  78. */
  79. onLoad: function (query) {
  80. const that = this;
  81. /* 获取最新供需列表 */
  82. _Http.basic({
  83. "accesstoken": wx.getStorageSync('userData').token,
  84. "classname": "customer.supplyanddemand.supplyanddemand",
  85. "method": "query_supplyanddemandList",
  86. "content": {
  87. "getdatafromdbanyway": true,
  88. "pageNumber": 1,
  89. "pageSize": 8,
  90. "where": {
  91. "fissupply": "0",
  92. "fstatus": "待对接"
  93. }
  94. }
  95. }).then(res => {
  96. if (res.msg != '成功') {
  97. wx.showToast({
  98. title: res.data,
  99. icon: "none"
  100. });
  101. if (query.q) {
  102. //有登录态直接加入
  103. analyze.setDataUrl(decodeURIComponent(query.q), true);
  104. console.log('登录态')
  105. }
  106. return;
  107. }
  108. const data = handleList.getYTD(res.data);
  109. this.setData({
  110. productList: data
  111. });
  112. // 获取到二维码原始链接内容
  113. if (query.q) {
  114. //有登录态直接加入
  115. this.ifQrCodeType(analyze.setDataUrl(decodeURIComponent(query.q)));
  116. console.log('有登录态')
  117. } else if (wx.getStorageSync('qrCodeMsg')) {
  118. //判断缓存中是否存在
  119. this.ifQrCodeType(wx.getStorageSync('qrCodeMsg'));
  120. //返回数据后清空缓存
  121. setTimeout(() => {
  122. wx.removeStorageSync('qrCodeMsg');
  123. }, 500)
  124. };
  125. });
  126. /* 获取合作商家 */
  127. _Http.basic({
  128. "accesstoken": wx.getStorageSync('userData').token,
  129. "classname": "customer.tagents.tagents",
  130. "method": "query_cooperation",
  131. "content": {
  132. "getdatafromdbanyway": true,
  133. "pageNumber": 1,
  134. "pageSize": 9,
  135. "where": {
  136. "condition": "",
  137. "ftype": "",
  138. "fstatus": "合作"
  139. }
  140. }
  141. }).then(res => {
  142. if (res.msg != '成功') return wx.showToast({
  143. title: res.data,
  144. icon: "none"
  145. });
  146. let data = handleList.imageType(res.data, 'brandlogo')
  147. const partnerList = handleList.twoDimensionalArr(data, 3);
  148. this.setData({
  149. partnerList
  150. })
  151. })
  152. /* 获取轮播图 */
  153. const bannerList = wx.getStorageSync('bannerDataList').filter(value => value.flocation == 'home_head');
  154. this.setData({
  155. swiperBannerList: bannerList[0].banner
  156. });
  157. //获取信息数量
  158. this.selectComponent("#gxshuju").unReadMessageCount();
  159. setTimeout(() => {
  160. that.getTabBar().setData({
  161. 'tabbarList[3].fcount': getApp().globalData.msgFcount
  162. })
  163. }, 500)
  164. },
  165. /* 判断二维码类型 */
  166. ifQrCodeType(data) {
  167. let MyModelText = '';
  168. if (data.type == 'partner') {
  169. //申请合作
  170. MyModelText = '是否向“' + data.name + '”发送合作申请';
  171. } else if (data.type == 'shop') {
  172. //申请加入团队
  173. MyModelText = '申请加入“' + data.name + '”团队';
  174. };
  175. this.setData({
  176. MyModelText,
  177. codeMsg: data,
  178. MyModelShow: true
  179. })
  180. },
  181. /* 首页模态框回调 */
  182. MyShowModelCallBack({
  183. detail
  184. }) {
  185. if (detail == 'true') {
  186. if (this.data.codeMsg.type == 'partner') {
  187. //申请合作
  188. _Http.basic({
  189. "accesstoken": wx.getStorageSync('userData').token,
  190. "classname": "customer.tagents.tagents",
  191. "method": "apply_cooperation",
  192. "content": {
  193. "tcooperationagentsid": this.data.codeMsg.id
  194. }
  195. }).then(res => {
  196. if (res.msg != '成功') return wx.showToast({
  197. title: res.data,
  198. icon: "none"
  199. });
  200. wx.showToast({
  201. title: "合作申请成功",
  202. });
  203. });
  204. } else if (this.data.codeMsg.type == 'shop') {
  205. //申请加入团队
  206. _Http.basic({
  207. "classname": "publicmethod.users.Users",
  208. "method": "entryTeamApply",
  209. "content": {
  210. "userid": wx.getStorageSync('userData').userid,
  211. "tagentsid": this.data.codeMsg.id
  212. }
  213. }).then(res => {
  214. if (res.data != '成功') return wx.showToast({
  215. title: res.data,
  216. icon: "none"
  217. });
  218. wx.showToast({
  219. title: "申请成功",
  220. icon: "none"
  221. });
  222. })
  223. }
  224. } else {
  225. this.setData({
  226. MyModelShow: false,
  227. codeMsg: ''
  228. });
  229. }
  230. },
  231. /* 一键联系 */
  232. contact() {
  233. /* wx.showToast({
  234. title: '功能尚在开发',
  235. icon: "none"
  236. }) */
  237. },
  238. /**
  239. * 生命周期函数--监听页面初次渲染完成
  240. */
  241. onReady: function () {
  242. },
  243. /**
  244. * 生命周期函数--监听页面显示
  245. */
  246. onShow: function () {
  247. this.getTabBar().init();
  248. this.getTabBar().setData({
  249. 'tabbarList[3].fcount': getApp().globalData.msgFcount
  250. })
  251. },
  252. /**
  253. * 生命周期函数--监听页面隐藏
  254. */
  255. onHide: function () {
  256. },
  257. /**
  258. * 生命周期函数--监听页面卸载
  259. */
  260. onUnload: function () {
  261. },
  262. /**
  263. * 页面相关事件处理函数--监听用户下拉动作
  264. */
  265. onPullDownRefresh: function () {
  266. },
  267. /**
  268. * 页面上拉触底事件的处理函数
  269. */
  270. onReachBottom: function () {
  271. },
  272. /**
  273. * 用户点击右上角分享
  274. */
  275. onShareAppMessage: function () {
  276. }
  277. })