index.js 12 KB

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