index.js 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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. } else if (detail == '通告') {
  75. wx.navigateTo({
  76. url: '/pages/annunciate/index',
  77. })
  78. }
  79. },
  80. /* 跳转详情 */
  81. toDetails(e) {
  82. const {
  83. index
  84. } = e.currentTarget.dataset;
  85. wx.navigateTo({
  86. url: '/pages/annunciate/details?id=' + this.data.annunciateList[index].tnoticeid + '&type=0',
  87. })
  88. },
  89. /**
  90. * 生命周期函数--监听页面加载
  91. */
  92. onLoad: function (query) {
  93. const that = this;
  94. /* 获取最新供需列表 */
  95. _Http.basic({
  96. "accesstoken": wx.getStorageSync('userData').token,
  97. "classname": "customer.supplyanddemand.supplyanddemand",
  98. "method": "query_supplyanddemandList",
  99. "content": {
  100. "getdatafromdbanyway": true,
  101. "pageNumber": 1,
  102. "pageSize": 8,
  103. "where": {
  104. "fissupply": "0",
  105. "fstatus": "待对接"
  106. }
  107. }
  108. }).then(res => {
  109. if (res.msg != '成功') {
  110. wx.showToast({
  111. title: res.data,
  112. icon: "none"
  113. });
  114. if (query.q) {
  115. //有登录态直接加入
  116. analyze.setDataUrl(decodeURIComponent(query.q), true);
  117. console.log('登录态')
  118. }
  119. return;
  120. }
  121. const data = handleList.getYTD(res.data);
  122. this.setData({
  123. productList: data
  124. });
  125. // 获取到二维码原始链接内容
  126. if (query.q) {
  127. //有登录态直接加入
  128. this.ifQrCodeType(analyze.setDataUrl(decodeURIComponent(query.q)));
  129. console.log('有登录态')
  130. } else if (wx.getStorageSync('qrCodeMsg')) {
  131. //判断缓存中是否存在
  132. this.ifQrCodeType(wx.getStorageSync('qrCodeMsg'));
  133. //返回数据后清空缓存
  134. setTimeout(() => {
  135. wx.removeStorageSync('qrCodeMsg');
  136. }, 500)
  137. };
  138. });
  139. /* 获取合作商家 */
  140. _Http.basic({
  141. "accesstoken": wx.getStorageSync('userData').token,
  142. "classname": "customer.tagents.tagents",
  143. "method": "query_cooperation",
  144. "content": {
  145. "getdatafromdbanyway": true,
  146. "pageNumber": 1,
  147. "pageSize": 9,
  148. "where": {
  149. "condition": "",
  150. "ftype": "",
  151. "fstatus": "合作"
  152. }
  153. }
  154. }).then(res => {
  155. if (res.msg != '成功') return wx.showToast({
  156. title: res.data,
  157. icon: "none"
  158. });
  159. let data = handleList.imageType(res.data, 'brandlogo')
  160. const partnerList = handleList.twoDimensionalArr(data, 3);
  161. this.setData({
  162. partnerList
  163. })
  164. })
  165. /* 获取通告 */
  166. _Http.basic({
  167. "accesstoken": wx.getStorageSync('userData').token,
  168. "classname": "customer.notice.notice",
  169. "method": "query_noticeList",
  170. "content": {
  171. "getdatafromdbanyway": true,
  172. "pageNumber": 1,
  173. "pageSize": 8,
  174. "where": {
  175. "condition": "",
  176. "ftype": ""
  177. }
  178. }
  179. }).then(res => {
  180. if (res.msg != '成功') return wx.showToast({
  181. title: res.data,
  182. icon: "none"
  183. });
  184. let list = handleList.annunciateCheckdate(res.data),
  185. data = handleList.imageType(list, 'cover');
  186. this.setData({
  187. annunciateList: data
  188. })
  189. })
  190. /* 获取轮播图 */
  191. const bannerList = wx.getStorageSync('bannerDataList').filter(value => value.flocation == 'home_head');
  192. this.setData({
  193. swiperBannerList: bannerList[0].banner
  194. });
  195. //获取信息数量
  196. this.selectComponent("#gxshuju").unReadMessageCount();
  197. setTimeout(() => {
  198. that.getTabBar().setData({
  199. 'tabbarList[3].fcount': getApp().globalData.msgFcount
  200. })
  201. }, 500)
  202. },
  203. /* 判断二维码类型 */
  204. ifQrCodeType(data) {
  205. let MyModelText = '';
  206. if (data.type == 'partner') {
  207. //申请合作
  208. MyModelText = '是否向“' + data.name + '”发送合作申请';
  209. } else if (data.type == 'shop') {
  210. //申请加入团队
  211. MyModelText = '申请加入“' + data.name + '”团队';
  212. };
  213. this.setData({
  214. MyModelText,
  215. codeMsg: data,
  216. MyModelShow: true
  217. })
  218. },
  219. /* 首页模态框回调 */
  220. MyShowModelCallBack({
  221. detail
  222. }) {
  223. if (detail == 'true') {
  224. if (this.data.codeMsg.type == 'partner') {
  225. //申请合作
  226. _Http.basic({
  227. "accesstoken": wx.getStorageSync('userData').token,
  228. "classname": "customer.tagents.tagents",
  229. "method": "apply_cooperation",
  230. "content": {
  231. "tcooperationagentsid": this.data.codeMsg.id
  232. }
  233. }).then(res => {
  234. if (res.msg != '成功') return wx.showToast({
  235. title: res.data,
  236. icon: "none"
  237. });
  238. wx.showToast({
  239. title: "合作申请成功",
  240. });
  241. });
  242. } else if (this.data.codeMsg.type == 'shop') {
  243. //申请加入团队
  244. _Http.basic({
  245. "classname": "publicmethod.users.Users",
  246. "method": "entryTeamApply",
  247. "content": {
  248. "userid": wx.getStorageSync('userData').userid,
  249. "tagentsid": this.data.codeMsg.id
  250. }
  251. }).then(res => {
  252. if (res.data != '成功') return wx.showToast({
  253. title: res.data,
  254. icon: "none"
  255. });
  256. wx.showToast({
  257. title: "申请成功",
  258. icon: "none"
  259. });
  260. })
  261. }
  262. } else {
  263. this.setData({
  264. MyModelShow: false,
  265. codeMsg: ''
  266. });
  267. }
  268. },
  269. /* 一键联系 */
  270. contact() {
  271. /* wx.showToast({
  272. title: '功能尚在开发',
  273. icon: "none"
  274. }) */
  275. },
  276. /**
  277. * 生命周期函数--监听页面初次渲染完成
  278. */
  279. onReady: function () {
  280. },
  281. /**
  282. * 生命周期函数--监听页面显示
  283. */
  284. onShow: function () {
  285. this.getTabBar().init();
  286. this.getTabBar().setData({
  287. 'tabbarList[3].fcount': getApp().globalData.msgFcount
  288. })
  289. },
  290. /**
  291. * 生命周期函数--监听页面隐藏
  292. */
  293. onHide: function () {
  294. },
  295. /**
  296. * 生命周期函数--监听页面卸载
  297. */
  298. onUnload: function () {
  299. },
  300. /**
  301. * 页面相关事件处理函数--监听用户下拉动作
  302. */
  303. onPullDownRefresh: function () {
  304. },
  305. /**
  306. * 页面上拉触底事件的处理函数
  307. */
  308. onReachBottom: function () {
  309. },
  310. /**
  311. * 用户点击右上角分享
  312. */
  313. onShareAppMessage: function () {
  314. }
  315. })