index.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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. let shareTime = null;
  8. Page({
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. productList: [], //供需列表
  14. //轮播图列表
  15. swiperBannerList: [],
  16. portal_middle_1: '',
  17. /* 宫格列表 */
  18. gridList: [{
  19. text: '参展入口',
  20. icon: '/static/home-grid/icon-05.png'
  21. }, {
  22. text: '数据查询',
  23. icon: '/static/home-grid/icon-01.png'
  24. }, {
  25. text: '我要直播',
  26. icon: '/static/home-grid/icon-02.png'
  27. }, {
  28. text: '通知公告',
  29. icon: '/static/home-grid/icon-03.png'
  30. }],
  31. /* 圆角按钮tabs列表 */
  32. codeMsg: {}, //二维码信息
  33. MyModelShow: false, //二维码二次确认
  34. MyModelText: "", //提示框文本
  35. shareObj: null, //分享数据
  36. /* 分页 */
  37. pageNumber: 1,
  38. pageTotal: 1,
  39. ftype: "",
  40. condition: ""
  41. },
  42. /* 宫格区跳转 */
  43. gridJumpPage(e) {
  44. const {
  45. name
  46. } = e.target.dataset;
  47. if (name == '供需广场') {
  48. wx.switchTab({
  49. url: '/pages/tabbar-pages/supplyAndDemand/index',
  50. })
  51. } else if (name == '我要直播') {
  52. wx.navigateTo({
  53. url: '/pages/liveStreaming/index',
  54. })
  55. } else if (name == '通知公告') {
  56. wx.navigateTo({
  57. url: '/pages/annunciate/index',
  58. })
  59. } else if (name == '数据查询') {
  60. wx.navigateTo({
  61. url: '/pages/tabbar-pages/home/analysis/index',
  62. })
  63. } else if (name == '参展入口') {
  64. const data = this.data.portal_middle_1;
  65. if (data.length == 0) return wx.showToast({
  66. title: '暂无展会活动',
  67. icon: "none"
  68. })
  69. wx.navigateTo({
  70. url: '/pages/scanQRCodes/register?id=' + data[0].fdataid,
  71. })
  72. } else {
  73. wx.showToast({
  74. title: '功能开发中',
  75. icon: "none"
  76. })
  77. }
  78. },
  79. /* 获取最新供需列表 */
  80. supplyanddemandList() {
  81. if (this.data.pageNumber > this.data.pageTotal) return;
  82. _Http.basic({
  83. "classname": "publicmethod.homepage.homepage",
  84. "method": "query_supplyanddemandList",
  85. "content": {
  86. "getdatafromdbanyway": true,
  87. "pageNumber": this.data.pageNumber,
  88. "pageSize": this.data.pageNumber == 1 ? 10 : 20,
  89. "siteid": "BWJ",
  90. "where": {
  91. "ftype": this.data.ftype,
  92. "condition": this.data.condition,
  93. "fissupply": "0",
  94. "fstatus": "待对接"
  95. }
  96. }
  97. }).then(res => {
  98. console.log('供需列表', res)
  99. if (res.msg != '成功') return wx.showToast({
  100. title: res.data,
  101. icon: "none"
  102. });
  103. if (res.data.length >= 1) {
  104. let data = handleList.getYTD(res.data),
  105. productList = null;
  106. res.pageNumber == 1 ? productList = data : productList = this.data.productList.concat(data);
  107. this.setData({
  108. productList,
  109. pageTotal: res.pageTotal
  110. });
  111. }
  112. });
  113. },
  114. /**
  115. * 生命周期函数--监听页面加载
  116. */
  117. onLoad: function (query) {
  118. const that = this;
  119. // 获取到二维码原始链接内容
  120. if (query.q) {
  121. this.ifQrCodeType(analyze.setDataUrl(decodeURIComponent(query.q)));
  122. } else if (wx.getStorageSync('qrCodeMsg')) {
  123. this.ifQrCodeType(wx.getStorageSync('qrCodeMsg'));
  124. };
  125. /* 获取最新供需列表 */
  126. this.supplyanddemandList();
  127. /* 获取轮播图 */
  128. const getBan = setInterval(() => {
  129. if (wx.getStorageSync('bannerDataList')) {
  130. const bannerList = wx.getStorageSync('bannerDataList').filter(value => value.flocation == 'home_head'),
  131. portal_middle_1 = wx.getStorageSync('bannerDataList').filter(value => value.flocation == 'portal_middle_1');
  132. this.setData({
  133. swiperBannerList: bannerList[0].banner,
  134. portal_middle_1: portal_middle_1[0].banner
  135. });
  136. clearInterval(getBan)
  137. }
  138. }, 300);
  139. //获取信息数量
  140. this.selectComponent("#gxshuju").unReadMessageCount();
  141. setTimeout(() => {
  142. that.getTabBar().setData({
  143. 'tabbarList[3].fcount': getApp().globalData.msgFcount
  144. })
  145. }, 500)
  146. //判断是否有门户直播登录
  147. if (wx.getStorageSync('liveUrl')) {
  148. wx.navigateTo({
  149. url: '/pages/webView/index?url=' + wx.getStorageSync('liveUrl'),
  150. })
  151. wx.removeStorage({
  152. key: 'liveUrl',
  153. })
  154. }
  155. },
  156. /* 二维码操作 */
  157. ifQrCodeType(data) {
  158. if (!wx.getStorageSync('userData')) return;
  159. let MyModelText = '',
  160. tagentsid = wx.getStorageSync('userData').tagentsid;
  161. if (data.id == tagentsid) {
  162. wx.removeStorageSync('qrCodeMsg');
  163. return wx.showToast({
  164. title: "您已经加入该团队",
  165. icon: "none"
  166. })
  167. }
  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. wx.removeStorageSync('qrCodeMsg');
  181. },
  182. /* 首页模态框回调 */
  183. MyShowModelCallBack({
  184. detail
  185. }) {
  186. if (detail == 'true') {
  187. if (this.data.codeMsg.type == 'partner') {
  188. //申请合作
  189. _Http.basic({
  190. "accesstoken": wx.getStorageSync('userData').token,
  191. "classname": "customer.tagents.tagents",
  192. "method": "apply_cooperation",
  193. "content": {
  194. "tcooperationagentsid": this.data.codeMsg.id
  195. }
  196. }).then(res => {
  197. if (res.msg != '成功') return wx.showToast({
  198. title: res.data,
  199. icon: "none"
  200. });
  201. wx.showToast({
  202. title: "合作申请成功",
  203. });
  204. });
  205. } else if (this.data.codeMsg.type == 'shop') {
  206. //申请加入团队
  207. _Http.basic({
  208. "classname": "publicmethod.users.Users",
  209. "method": "entryTeamApply",
  210. "content": {
  211. "userid": wx.getStorageSync('userData').userid,
  212. "tagentsid": this.data.codeMsg.id
  213. }
  214. }).then(res => {
  215. if (res.data != '成功') return wx.showToast({
  216. title: res.data,
  217. icon: "none"
  218. });
  219. wx.showToast({
  220. title: "申请成功",
  221. icon: "none"
  222. });
  223. })
  224. }
  225. } else {
  226. this.setData({
  227. MyModelShow: false,
  228. codeMsg: ''
  229. });
  230. }
  231. },
  232. /**
  233. * 生命周期函数--监听页面初次渲染完成
  234. */
  235. onReady: function () {
  236. },
  237. /**
  238. * 生命周期函数--监听页面显示
  239. */
  240. onShow: function () {
  241. this.getTabBar().init();
  242. this.getTabBar().setData({
  243. 'tabbarList[3].fcount': getApp().globalData.msgFcount
  244. })
  245. },
  246. /**
  247. * 生命周期函数--监听页面隐藏
  248. */
  249. onHide: function () {
  250. },
  251. /**
  252. * 生命周期函数--监听页面卸载
  253. */
  254. onUnload: function () {
  255. },
  256. /**
  257. * 页面相关事件处理函数--监听用户下拉动作
  258. */
  259. onPullDownRefresh: function () {
  260. },
  261. /**
  262. * 页面上拉触底事件的处理函数
  263. */
  264. onReachBottom: function () {
  265. this.setData({
  266. pageNumber: this.data.pageNumber + 1
  267. })
  268. this.supplyanddemandList()
  269. },
  270. /* 回调 */
  271. shareCallBack({
  272. detail
  273. }) {
  274. this.setData({
  275. shareObj: detail
  276. })
  277. },
  278. /**
  279. * 用户点击右上角分享
  280. */
  281. /* */
  282. onShareAppMessage: function (e) {
  283. const that = this;
  284. if (e.from == 'button') {
  285. const promise = new Promise(resolve => {
  286. shareTime = setInterval(() => {
  287. if (that.data.shareObj != null) {
  288. let str = JSON.stringify(that.data.shareObj),
  289. obj = JSON.parse(str);
  290. that.setData({
  291. shareObj: null
  292. })
  293. clearInterval(shareTime);
  294. resolve({
  295. title: obj.ftitle,
  296. path: '/pages/tabbar-pages/home/sdDetalis?item=' + str,
  297. imageUrl: obj.attinfos.length >= 1 ? obj.attinfos[0].fobsurl : '',
  298. success: function (res) {
  299. if (res.errMsg == 'shareAppMessage:ok') {
  300. wx.showToast({
  301. title: '分享成功',
  302. })
  303. }
  304. },
  305. })
  306. }
  307. }, 300)
  308. })
  309. return {
  310. title: '自定义转发标题',
  311. path: '/page/user?id=123',
  312. promise
  313. }
  314. /* */
  315. } else {
  316. console.log('页面分享')
  317. }
  318. }
  319. })