index.js 10 KB

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