抖音c端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

244 line
5.4 KiB

  1. // c:\Users\Holy-Knight-IX\Desktop\Working Space\4.TikTok-MiniPro\ttc\package2\pages\appointment\appointment.js
  2. let config = require("../../../config/config.js");
  3. let util = require("../../../utils/util");
  4. let Http = require("../../../utils/HttpBasics");
  5. let app = getApp();
  6. const imgurl = require("../../../utils/imgurl");
  7. Page({
  8. data: {
  9. appointmentText: "确认预约",
  10. id: "",
  11. orderId: "",
  12. startTime: "",
  13. endTime: "",
  14. mallTenantId: "",
  15. pickedAddress: "请选择地址",
  16. pickedDate: "请选择日期",
  17. pickedStartTime: "请选择",
  18. pickedEndTime: "请选择",
  19. describeStr: "",
  20. status: ""
  21. },
  22. onLoad(options) {
  23. console.log(options, 'options');
  24. this.setData({
  25. id: options.id || '',
  26. orderId: options.orderId || '',
  27. startTime: options.startTime || '',
  28. endTime: options.endTime || ''
  29. })
  30. const mallTenantId = tt.getStorageSync('mallTenantId');
  31. if (mallTenantId) {
  32. this.setData({
  33. mallTenantId
  34. })
  35. }
  36. if (this.data.id) {
  37. this.getDetail(this.data.id)
  38. }
  39. },
  40. chooseAddress() {
  41. let that = this;
  42. tt.chooseLocation({
  43. success: function (res) {
  44. that.setData({
  45. pickedAddress: res.address,
  46. })
  47. },
  48. fail: function (error) {
  49. console.log(error)
  50. },
  51. complete: function (data) {}
  52. })
  53. },
  54. chooseDate(e) {
  55. console.log(e.detail.value, 'e');
  56. this.setData({
  57. pickedDate: e.detail.value
  58. })
  59. },
  60. chooseStartTime(e) {
  61. console.log(e.detail.value, 'e');
  62. this.setData({
  63. pickedStartTime: e.detail.value
  64. })
  65. },
  66. chooseEndTime(e) {
  67. console.log(e.detail.value, 'e');
  68. this.setData({
  69. pickedEndTime: e.detail.value
  70. })
  71. },
  72. describing(e) {
  73. this.setData({
  74. describeStr: e.detail.value
  75. })
  76. },
  77. confirm() {
  78. const tempData = this.data
  79. if (tempData.pickedAddress == '请选择地址') {
  80. tt.showToast({
  81. title: '请选择地址!',
  82. icon: 'fail'
  83. });
  84. return
  85. }
  86. if (tempData.pickedDate == '请选择日期') {
  87. tt.showToast({
  88. title: '请请选择日期!',
  89. icon: 'fail'
  90. });
  91. return
  92. }
  93. if (tempData.pickedStartTime == '请选择') {
  94. tt.showToast({
  95. title: '请起始时间!',
  96. icon: 'fail'
  97. });
  98. return
  99. }
  100. if (tempData.pickedEndTime == '请选择') {
  101. tt.showToast({
  102. title: '请结束时间!',
  103. icon: 'fail'
  104. });
  105. return
  106. }
  107. const data = {
  108. couponOrderId: tempData.orderId,
  109. userAddress: tempData.pickedAddress,
  110. startDate: tempData.pickedDate + " " + tempData.pickedStartTime + ":00",
  111. endDate: tempData.pickedDate + " " + tempData.pickedEndTime + ":00",
  112. describeStr: tempData.describeStr,
  113. mallTenantId: tempData.mallTenantId || ''
  114. }
  115. if (this.data.id) {
  116. data.id = this.data.id
  117. }
  118. if (this.data.status == 1) {
  119. data.status = 0
  120. }
  121. console.log(data, 'data');
  122. this.saveOrderReservation(data)
  123. },
  124. cancel() {
  125. tt.showModal({
  126. title: "取消预约",
  127. content: "确定要取消预约吗?",
  128. showCancel: true,
  129. success: (res) => {
  130. if (res.confirm) {
  131. this.cancelReservation(this.data.id)
  132. }
  133. if (res.cancel) {
  134. return
  135. }
  136. },
  137. fail: (res) => {
  138. },
  139. });
  140. },
  141. cancelReservation(id) {
  142. const that = this
  143. Http.post({
  144. url: config.api.cancelReservation,
  145. data: {
  146. id,
  147. mallTenantId: this.data.mallTenantId || ''
  148. }
  149. }).then(res => {
  150. console.log(res, 'cancelReservation');
  151. tt.showToast({
  152. title: '取消成功!',
  153. icon: 'success',
  154. duration: 2000,
  155. success: (res) => {
  156. setTimeout(() => {
  157. tt.navigateBack();
  158. }, 1500);
  159. },
  160. fail: (res) => {
  161. },
  162. });
  163. }).catch(err => {
  164. console.log(err, 'cancelReservation');
  165. tt.showToast({
  166. title: err.message,
  167. icon: 'none'
  168. });
  169. })
  170. },
  171. saveOrderReservation(data) {
  172. Http.post({
  173. url: config.api.saveOrderReservation,
  174. data
  175. }).then(res => {
  176. console.log(res, 'saveOrderReservation');
  177. tt.showToast({
  178. title: '预约成功!',
  179. icon: 'success',
  180. duration: 2000,
  181. success: (res) => {
  182. setTimeout(() => {
  183. tt.navigateBack();
  184. }, 1500);
  185. },
  186. fail: (res) => {
  187. },
  188. });
  189. }).catch(err => {
  190. console.log(err, 'saveOrderReservation');
  191. tt.showToast({
  192. title: err.message,
  193. icon: 'none'
  194. });
  195. })
  196. },
  197. getDetail(id) {
  198. const that = this
  199. Http.get({
  200. url: config.api.getOrderReservationDetail,
  201. data: {
  202. id,
  203. mallTenantId: this.data.mallTenantId || ''
  204. }
  205. }).then(res => {
  206. console.log(res, 'getOrderReservationDetail');
  207. that.setData({
  208. pickedAddress: res.data.userAddress || '请选择地址',
  209. pickedDate: util.timestampToTime(res.data.startDate, 'YYYY-MM-DD'),
  210. pickedStartTime: util.timestampToTime(res.data.startDate, 'hh:mm'),
  211. pickedEndTime: util.timestampToTime(res.data.endDate, 'hh:mm'),
  212. describeStr: res.data.describeStr,
  213. status: res.data.status,
  214. appointmentText: res.data.status == 1 ? "重新预约" : "修改预约"
  215. })
  216. }).catch(err => {
  217. console.log(err, 'getOrderReservationDetail');
  218. })
  219. }
  220. })