抖音c端
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

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