addmeet.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. // pages/my/meet/detail.js
  2. const App = getApp();
  3. var util = require("../../utils/util.js");
  4. let timer = null;
  5. let sNum = 0
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. appAssetsUrl2: App.appAssetsUrl2,
  12. meetId: null,
  13. expertId: null,
  14. memberId: null, //拼主id
  15. detail: {},
  16. expertDetail: {},
  17. groupList: [],
  18. experienceDetail: {},
  19. h: "00",
  20. m: "00",
  21. s: "00",
  22. queryPage: {
  23. page: 1,
  24. limit: 10,
  25. },
  26. list: [],
  27. total: null,
  28. totalPage: null,
  29. currPage: null,
  30. user: wx.getStorageSync("USER"),
  31. },
  32. /**
  33. * 生命周期函数--监听页面加载
  34. */
  35. onLoad(options) {
  36. console.log(options);
  37. this.setData({
  38. meetId: options.meetId,
  39. expertId: options.expertId,
  40. memberId: options.memberId
  41. });
  42. this.getDetail(options.meetId);
  43. this.getExpert();
  44. },
  45. /**
  46. * 生命周期函数--监听页面初次渲染完成
  47. */
  48. onReady() {
  49. this.popup2 = this.selectComponent("#popup2");
  50. },
  51. /**
  52. * 生命周期函数--监听页面显示
  53. */
  54. onShow() {},
  55. getDetail(meetId) {
  56. wx.showLoading({
  57. title: "努力加载中...",
  58. });
  59. App._get(
  60. `myMeet/myAppointmentInfo`,
  61. {
  62. meetId: meetId,
  63. id: this.data.memberId,
  64. },
  65. (res) => {
  66. if (res.code === 0) {
  67. this.setData({
  68. detail: res.data,
  69. groupList: res.data.meetPeopleBOList,
  70. });
  71. if (res.data.process >= 3) {
  72. this.getExperience(res.data.meetId);
  73. }
  74. if (
  75. res.data.groupWay == 1 &&
  76. res.data.process == 0 &&
  77. res.data.meetType == 0
  78. ) {
  79. sNum = 0
  80. timer = setInterval(this.countDown, 1000);
  81. }
  82. wx.hideLoading();
  83. }
  84. },
  85. (err) => {},
  86. (complete) => {}
  87. );
  88. },
  89. // 立即参团 /pages/login
  90. addsub() {
  91. if(!util.getUserId()) {
  92. wx.navigateTo({
  93. url: `/pages/login?meetId=${this.data.meetId}&expertId=${this.data.expertId}&memberId=${this.data.memberId}`,
  94. })
  95. return
  96. }
  97. console.log('1111111111111')
  98. App._put_form(
  99. "meet/joinTheGroup",
  100. "",
  101. {
  102. id: util.getUserId(),
  103. // id: this.data.memberId,
  104. meetId: this.data.meetId,
  105. },
  106. (res) => {
  107. if (res.code === 0) {
  108. wx.showActionSheet({
  109. itemList: ["微信支付"],
  110. success: (response) => {
  111. if (response.tapIndex === 0) {
  112. wx.showLoading({
  113. title: "正在处理...",
  114. mask: true,
  115. });
  116. wx.requestPayment({
  117. timeStamp: res.map.timestamp,
  118. nonceStr: res.map.nonce_str,
  119. package: "prepay_id=" + res.map.prepay_id,
  120. signType: "MD5",
  121. paySign: res.map.sign,
  122. success: (result) => {
  123. if (result.errMsg == "requestPayment:ok") {
  124. wx.showLoading({
  125. title: "正在处理...",
  126. mask: true,
  127. });
  128. console.log(result, 11111111);
  129. wx.hideLoading();
  130. wx.showToast({
  131. title: "拼团成功",
  132. icon: "success",
  133. });
  134. wx.navigateTo({
  135. url:
  136. "/expert/success/success?expertId=" +
  137. this.data.expertId +
  138. "&meetId=" +
  139. res.map.businessId +
  140. "&onePer=" +
  141. false,
  142. });
  143. } else {
  144. wx.hideLoading();
  145. wx.showToast({
  146. title: "支付失败!",
  147. icon: "none",
  148. duration: 1500,
  149. });
  150. }
  151. },
  152. fail: (error) => {
  153. wx.hideLoading();
  154. wx.showToast({
  155. title: "支付失败!",
  156. icon: "none",
  157. duration: 1500,
  158. });
  159. },
  160. });
  161. }
  162. },
  163. });
  164. // this.getGroupList();
  165. }
  166. }
  167. );
  168. },
  169. // 获取行家详情
  170. getExpert() {
  171. App._get(`expert/info/${this.data.expertId}`, {}, (res) => {
  172. if (res.code === 0) {
  173. this.setData({
  174. expertDetail: res.expert,
  175. });
  176. }
  177. });
  178. },
  179. // 获取心得分享
  180. getExperience(meetId) {
  181. if (this.data.queryPage.page > 1) {
  182. if (this.data.total > 0 && this.data.currPage == this.data.totalPage) {
  183. wx.showToast({
  184. title: "没有更多了~",
  185. icon: "none",
  186. });
  187. return false;
  188. }
  189. }
  190. wx.showLoading({
  191. title: "努力加载中...",
  192. });
  193. App._get(
  194. "meetevaluation/evaluatePage",
  195. {
  196. meetId: meetId,
  197. ...this.data.queryPage,
  198. },
  199. (res) => {
  200. if (res.code === 0) {
  201. this.setData({
  202. list: [...this.data.list, ...res.page.list],
  203. total: res.page.totalCount,
  204. totalPage: res.page.totalPage,
  205. currPage: res.page.currPage,
  206. });
  207. }
  208. },
  209. (err) => {},
  210. (complete) => {
  211. setTimeout(() => {
  212. wx.hideLoading();
  213. }, 500);
  214. }
  215. );
  216. },
  217. // 查看更多
  218. lookMore() {
  219. wx.navigateTo({
  220. url: "/meet/meet/meet",
  221. });
  222. },
  223. // 取消预约
  224. closeMakeHandle() {
  225. this.popup2.showPopup();
  226. },
  227. // 心得分享
  228. experienceSharingHandle() {
  229. wx.navigateTo({
  230. url: `/meet/experience/experience?meetId=${this.data.meetId}&expertId=${this.data.expertId}&topicId=${this.data.detail.topicId}&memberId=${this.data.expertDetail.memberId}`,
  231. });
  232. },
  233. _error() {
  234. console.log("返回");
  235. this.popup2.hidePopup();
  236. },
  237. // 确认取消预约
  238. _success() {
  239. console.log("查看");
  240. wx.showLoading({
  241. title: "取消中...",
  242. });
  243. App._put_form(
  244. "myMeet/cancelAppointment",
  245. "",
  246. {
  247. id: this.data.user.id,
  248. meetId: this.data.meetId,
  249. },
  250. (res) => {
  251. if (res.code === 0) {
  252. this.popup2.hidePopup();
  253. wx.hideLoading();
  254. wx.navigateBack();
  255. wx.showToast({
  256. title: "已取消预约",
  257. });
  258. }
  259. },
  260. (err) => {
  261. wx.showToast({
  262. icon: "error",
  263. title: "服务端异常",
  264. });
  265. }
  266. );
  267. },
  268. // 完成请教
  269. finishHandle() {
  270. App._put_form(
  271. "myMeet/completeTheConsultation",
  272. "",
  273. {
  274. id: this.data.user.id,
  275. meetId: this.data.meetId,
  276. },
  277. (res) => {
  278. if (res.code === 0) {
  279. wx.navigateBack();
  280. wx.showToast({
  281. title: "请教成功",
  282. });
  283. }
  284. }
  285. );
  286. },
  287. contactExpert() {
  288. this.setData({
  289. isShowContact: true,
  290. });
  291. },
  292. cancelContact() {
  293. this.setData({
  294. isShowContact: false,
  295. });
  296. },
  297. contactPhone(e) {
  298. console.log(e, 1111);
  299. wx.makePhoneCall({
  300. phoneNumber: e.currentTarget.dataset.phone,
  301. });
  302. this.setData({
  303. isShowContact: false,
  304. });
  305. },
  306. toCustomer() {
  307. wx.navigateTo({
  308. url: "/pages/my/myCustomer/myCustomer",
  309. });
  310. },
  311. //统计积分(每日小程序分享)
  312. addScore: function () {
  313. if (!util.getUserId()) {
  314. return;
  315. }
  316. let _this = this;
  317. wx.showLoading({
  318. title: "努力加载中...",
  319. });
  320. App._post_form(
  321. "scoreStu/share",
  322. "",
  323. {
  324. stuId: util.getUserId(),
  325. },
  326. function (res) {
  327. if (res.code === 0) {
  328. wx.hideLoading();
  329. }
  330. }
  331. );
  332. },
  333. // 倒计时
  334. countDown() {
  335. sNum++
  336. let endTime = new Date(this.data.detail.groupWayEndTime).getTime();
  337. let nowTime = this.data.detail.currentTimeStamp;
  338. let times = (endTime - nowTime) / 1000 - sNum;
  339. if (times > 0) {
  340. let h = parseInt(times / 60 / 60);
  341. h = h < 10 ? "0" + h : h;
  342. let m = parseInt((times / 60) % 60);
  343. m = m < 10 ? "0" + m : m;
  344. let s = parseInt(times % 60);
  345. s = s < 10 ? "0" + s : s;
  346. this.setData({
  347. h: h,
  348. m: m,
  349. s: s,
  350. });
  351. if (h == "00" && m == "00" && s == "00") {
  352. clearInterval(timer);
  353. sNum = 0
  354. setTimeout(() => {
  355. wx.showToast({
  356. title: "时间到了",
  357. });
  358. }, 1);
  359. this.getDetail(this.data.meetId);
  360. this.getExpert();
  361. }
  362. } else {
  363. clearInterval(timer);
  364. sNum = 0
  365. }
  366. },
  367. /**
  368. * 生命周期函数--监听页面隐藏
  369. */
  370. onHide() {},
  371. /**
  372. * 生命周期函数--监听页面卸载
  373. */
  374. onUnload() {
  375. clearInterval(timer);
  376. sNum = 0
  377. },
  378. /**
  379. * 页面相关事件处理函数--监听用户下拉动作
  380. */
  381. onPullDownRefresh() {},
  382. /**
  383. * 页面上拉触底事件的处理函数
  384. */
  385. onReachBottom() {
  386. if (this.data.detail.process >= 3) {
  387. this.setData({
  388. queryPage: {
  389. page: ++this.data.queryPage.page,
  390. limit: 10,
  391. },
  392. });
  393. this.getExperience(this.meetId);
  394. }
  395. },
  396. /**
  397. * 用户点击右上角分享
  398. */
  399. // onShareAppMessage() {
  400. // },
  401. });