index.js 11 KB

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