index.js 11 KB

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