index.js 12 KB

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