index.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  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: '/static/home-grid/icon-01.png'
  19. }, {
  20. text: '私域直播',
  21. icon: '/static/home-grid/icon-02.png'
  22. }, {
  23. text: '通告',
  24. icon: '/static/home-grid/icon-03.png'
  25. }, {
  26. text: '供需广场',
  27. icon: '/static/home-grid/icon-04.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. console.log("res.data", res.data)
  154. if (res.data.length >= 1) {
  155. const data = handleList.getYTD(res.data);
  156. this.setData({
  157. productList: data
  158. });
  159. }
  160. // 获取到二维码原始链接内容
  161. if (query.q) {
  162. //有登录态直接加入
  163. this.ifQrCodeType(analyze.setDataUrl(decodeURIComponent(query.q)));
  164. console.log('有登录态')
  165. } else if (wx.getStorageSync('qrCodeMsg')) {
  166. //判断缓存中是否存在
  167. this.ifQrCodeType(wx.getStorageSync('qrCodeMsg'));
  168. //返回数据后清空缓存
  169. setTimeout(() => {
  170. wx.removeStorageSync('qrCodeMsg');
  171. }, 500)
  172. };
  173. });
  174. /* 获取合作商家 */
  175. _Http.basic({
  176. "accesstoken": wx.getStorageSync('userData').token,
  177. "classname": "customer.tagents.tagents",
  178. "method": "query_cooperation",
  179. "content": {
  180. "getdatafromdbanyway": true,
  181. "pageNumber": 1,
  182. "pageSize": 9,
  183. "where": {
  184. "condition": "",
  185. "ftype": "",
  186. "fstatus": "合作"
  187. }
  188. }
  189. }).then(res => {
  190. if (res.msg != '成功') return wx.showToast({
  191. title: res.data,
  192. icon: "none"
  193. });
  194. let data = handleList.imageType(res.data, 'brandlogo')
  195. const partnerList = handleList.twoDimensionalArr(data, 3);
  196. this.setData({
  197. partnerList
  198. })
  199. })
  200. /* 获取通告 */
  201. _Http.basic({
  202. "accesstoken": wx.getStorageSync('userData').token,
  203. "classname": "customer.notice.notice",
  204. "method": "query_noticeList",
  205. "content": {
  206. "getdatafromdbanyway": true,
  207. "pageNumber": 1,
  208. "pageSize": 8,
  209. "where": {
  210. "condition": "",
  211. "ftype": ""
  212. }
  213. }
  214. }).then(res => {
  215. if (res.msg != '成功') return wx.showToast({
  216. title: res.data,
  217. icon: "none"
  218. });
  219. let list = handleList.annunciateCheckdate(res.data),
  220. data = handleList.imageType(list, 'cover');
  221. this.setData({
  222. annunciateList: data
  223. })
  224. })
  225. /* 获取轮播图 */
  226. const bannerList = wx.getStorageSync('bannerDataList').filter(value => value.flocation == 'home_head');
  227. this.setData({
  228. swiperBannerList: bannerList[0].banner
  229. });
  230. //获取信息数量
  231. this.selectComponent("#gxshuju").unReadMessageCount();
  232. setTimeout(() => {
  233. that.getTabBar().setData({
  234. 'tabbarList[3].fcount': getApp().globalData.msgFcount
  235. })
  236. }, 500)
  237. },
  238. /* 判断二维码类型 */
  239. ifQrCodeType(data) {
  240. let MyModelText = '';
  241. let tagentsid = wx.getStorageSync('account_list')[0].tagentsid;
  242. console.log(tagentsid, data.id)
  243. if (data.id == tagentsid) return wx.showToast({
  244. title: "您已经加入该团队",
  245. icon: "none"
  246. })
  247. if (data.type == 'partner') {
  248. //申请合作
  249. MyModelText = '是否向“' + data.name + '”发送合作申请';
  250. } else if (data.type == 'shop') {
  251. //申请加入团队
  252. MyModelText = '申请加入“' + data.name + '”团队';
  253. };
  254. this.setData({
  255. MyModelText,
  256. codeMsg: data,
  257. MyModelShow: true
  258. })
  259. },
  260. /* 首页模态框回调 */
  261. MyShowModelCallBack({
  262. detail
  263. }) {
  264. if (detail == 'true') {
  265. if (this.data.codeMsg.type == 'partner') {
  266. //申请合作
  267. _Http.basic({
  268. "accesstoken": wx.getStorageSync('userData').token,
  269. "classname": "customer.tagents.tagents",
  270. "method": "apply_cooperation",
  271. "content": {
  272. "tcooperationagentsid": this.data.codeMsg.id
  273. }
  274. }).then(res => {
  275. if (res.msg != '成功') return wx.showToast({
  276. title: res.data,
  277. icon: "none"
  278. });
  279. wx.showToast({
  280. title: "合作申请成功",
  281. });
  282. });
  283. } else if (this.data.codeMsg.type == 'shop') {
  284. //申请加入团队
  285. _Http.basic({
  286. "classname": "publicmethod.users.Users",
  287. "method": "entryTeamApply",
  288. "content": {
  289. "userid": wx.getStorageSync('userData').userid,
  290. "tagentsid": this.data.codeMsg.id
  291. }
  292. }).then(res => {
  293. if (res.data != '成功') return wx.showToast({
  294. title: res.data,
  295. icon: "none"
  296. });
  297. wx.showToast({
  298. title: "申请成功",
  299. icon: "none"
  300. });
  301. })
  302. }
  303. } else {
  304. this.setData({
  305. MyModelShow: false,
  306. codeMsg: ''
  307. });
  308. }
  309. },
  310. /**
  311. * 生命周期函数--监听页面初次渲染完成
  312. */
  313. onReady: function () {
  314. },
  315. /**
  316. * 生命周期函数--监听页面显示
  317. */
  318. onShow: function () {
  319. this.getTabBar().init();
  320. this.getTabBar().setData({
  321. 'tabbarList[3].fcount': getApp().globalData.msgFcount
  322. })
  323. },
  324. /**
  325. * 生命周期函数--监听页面隐藏
  326. */
  327. onHide: function () {
  328. },
  329. /**
  330. * 生命周期函数--监听页面卸载
  331. */
  332. onUnload: function () {
  333. },
  334. /**
  335. * 页面相关事件处理函数--监听用户下拉动作
  336. */
  337. onPullDownRefresh: function () {
  338. },
  339. /**
  340. * 页面上拉触底事件的处理函数
  341. */
  342. onReachBottom: function () {
  343. },
  344. /**
  345. * 用户点击右上角分享
  346. */
  347. onShareAppMessage: function () {
  348. }
  349. })