index.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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. if (data.type == 'partner') {
  242. //申请合作
  243. MyModelText = '是否向“' + data.name + '”发送合作申请';
  244. } else if (data.type == 'shop') {
  245. //申请加入团队
  246. MyModelText = '申请加入“' + data.name + '”团队';
  247. };
  248. this.setData({
  249. MyModelText,
  250. codeMsg: data,
  251. MyModelShow: true
  252. })
  253. },
  254. /* 首页模态框回调 */
  255. MyShowModelCallBack({
  256. detail
  257. }) {
  258. if (detail == 'true') {
  259. if (this.data.codeMsg.type == 'partner') {
  260. //申请合作
  261. _Http.basic({
  262. "accesstoken": wx.getStorageSync('userData').token,
  263. "classname": "customer.tagents.tagents",
  264. "method": "apply_cooperation",
  265. "content": {
  266. "tcooperationagentsid": this.data.codeMsg.id
  267. }
  268. }).then(res => {
  269. if (res.msg != '成功') return wx.showToast({
  270. title: res.data,
  271. icon: "none"
  272. });
  273. wx.showToast({
  274. title: "合作申请成功",
  275. });
  276. });
  277. } else if (this.data.codeMsg.type == 'shop') {
  278. //申请加入团队
  279. _Http.basic({
  280. "classname": "publicmethod.users.Users",
  281. "method": "entryTeamApply",
  282. "content": {
  283. "userid": wx.getStorageSync('userData').userid,
  284. "tagentsid": this.data.codeMsg.id
  285. }
  286. }).then(res => {
  287. if (res.data != '成功') return wx.showToast({
  288. title: res.data,
  289. icon: "none"
  290. });
  291. wx.showToast({
  292. title: "申请成功",
  293. icon: "none"
  294. });
  295. })
  296. }
  297. } else {
  298. this.setData({
  299. MyModelShow: false,
  300. codeMsg: ''
  301. });
  302. }
  303. },
  304. /**
  305. * 生命周期函数--监听页面初次渲染完成
  306. */
  307. onReady: function () {
  308. },
  309. /**
  310. * 生命周期函数--监听页面显示
  311. */
  312. onShow: function () {
  313. this.getTabBar().init();
  314. this.getTabBar().setData({
  315. 'tabbarList[3].fcount': getApp().globalData.msgFcount
  316. })
  317. },
  318. /**
  319. * 生命周期函数--监听页面隐藏
  320. */
  321. onHide: function () {
  322. },
  323. /**
  324. * 生命周期函数--监听页面卸载
  325. */
  326. onUnload: function () {
  327. },
  328. /**
  329. * 页面相关事件处理函数--监听用户下拉动作
  330. */
  331. onPullDownRefresh: function () {
  332. },
  333. /**
  334. * 页面上拉触底事件的处理函数
  335. */
  336. onReachBottom: function () {
  337. },
  338. /**
  339. * 用户点击右上角分享
  340. */
  341. onShareAppMessage: function () {
  342. }
  343. })