packagedetail.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. const app = getApp()
  2. var util = require("../../../utils/util.js")
  3. Page({
  4. data: {
  5. p_name: undefined,
  6. p_code: undefined,
  7. PIGroups: [],
  8. PIClasses: [],
  9. PIServices: [],
  10. PIServiceLength: undefined,
  11. Showname: [],
  12. p_id: '',
  13. imgLists: []
  14. },
  15. onLoad: function(option) {
  16. this.setData({
  17. p_id: option.p_id
  18. })
  19. var that = this
  20. // 根据ID获取详情pic
  21. util.getData('/getPackageImagesByID', {
  22. p_id: that.data.p_id
  23. }).then(res => {
  24. // console.log(res);
  25. that.setData({
  26. imgLists: res
  27. })
  28. })
  29. util.getData('/getPackageDetail',{
  30. p_code: option.para
  31. }).then(res=>{
  32. that.setData({
  33. p_name: res.p_name,
  34. p_code: option.para,
  35. })
  36. })
  37. util.getData('/getPIGroups').then(res=>{
  38. that.setData({
  39. PIGroups: res
  40. })
  41. })
  42. util.getData('/getPIClasses').then(res=>{
  43. that.setData({
  44. PIClasses: res
  45. })
  46. })
  47. wx.request({
  48. url: app.globalData.url + '/getPIServices',
  49. method: 'get',
  50. success: function(res3) {
  51. that.setData({
  52. PIServices: res3.data,
  53. PIServiceLength: res3.data.length - 1
  54. })
  55. },
  56. fail() {
  57. app.timeOut()
  58. }
  59. })
  60. wx.request({
  61. url: app.globalData.url + '/getPackageShowname',
  62. method: 'get',
  63. success: function(res4) {
  64. that.setData({
  65. Showname: res4.data
  66. })
  67. },
  68. fail() {
  69. app.timeOut()
  70. }
  71. })
  72. let _this = this;
  73. _this.setData({
  74. navH: app.globalData.navHeight
  75. })
  76. },
  77. bookingpackages: function(e) {
  78. var that = this
  79. app.checkSession().then(res => {
  80. if (app.globalData.userphone == null) {
  81. app.ifAuthorization();
  82. } else {
  83. wx.showLoading({
  84. title: '保存中......',
  85. icon: 'loading',
  86. duration: 55000
  87. })
  88. //保存数据库
  89. var duedate = new Date();
  90. var year = duedate.getFullYear();
  91. var month = duedate.getMonth() + 1;
  92. var strDate = duedate.getDate();
  93. var seperator1 = "-";
  94. var date = new Date();
  95. var year = date.getFullYear();
  96. var month = ("0" + (date.getMonth() + 1)).slice(-2);;
  97. var strDate = ("0" + (date.getDate())).slice(-2);
  98. var hours = ("0" + (date.getHours())).slice(-2);
  99. var minutes = ("0" + (date.getMinutes())).slice(-2);
  100. var seconds = ("0" + (date.getSeconds())).slice(-2);
  101. var eh_time = year + '-' + month + '-' + strDate + ' ' + hours + ':' + minutes + ':' + seconds;
  102. util.getData('/getDcIntroducerConsultants', {
  103. dig_introducer_phone: app.globalData.introducer
  104. }).then(res => {
  105. if (res != null) {
  106. that.setData({
  107. consultants: res
  108. })
  109. }
  110. let branche_code = wx.getStorageSync('branche_code');
  111. util.postData('/insertCustomerBooking', {
  112. bk_phone: app.globalData.userphone,
  113. bk_date: year + seperator1 + month + seperator1 + strDate,
  114. bk_type: 1,
  115. bk_branches_id: branche_code,
  116. bk_desc: that.data.p_name,
  117. bk_introducer_phone: app.globalData.introducer,
  118. bk_introducer_consultant: that.data.consultants
  119. }).then(res => {
  120. wx.hideLoading()
  121. if (res > 1) {
  122. wx.showToast({
  123. title: '亲,您今天已经预约过了',
  124. icon: 'none',
  125. duration: 5000
  126. })
  127. } else {
  128. wx.showToast({
  129. title: '预约成功!',
  130. icon: 'success',
  131. duration: 5000
  132. })
  133. // 发送消息
  134. util.postData('/WXSendBookingMessage', {
  135. bk_phone: app.globalData.userphone,
  136. bk_type: 1,
  137. bk_date: eh_time,
  138. bk_desc: that.data.p_name,
  139. bk_branches_id: branche_code,
  140. bk_introducer_phone: app.globalData.introducer,
  141. bk_introducer_consultant: that.data.consultants
  142. })
  143. util.postData('/insertDcIntroduceLog', {
  144. xul_openid: app.globalData.openid,
  145. xul_phone: app.globalData.userphone,
  146. xul_event: 4,
  147. xul_introducer_phone: app.globalData.introducer
  148. })
  149. }
  150. })
  151. })
  152. }
  153. })
  154. },
  155. onShareAppMessage: function() {
  156. return {
  157. title: '悦所-套餐详情(' + this.data.p_name + ')',
  158. path: '/pages/index/index?skip=1&path=' + '/pages/packages/packagedetail/packagedetail&para=' + this.data.p_code
  159. }
  160. },
  161. })