index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <view>
  3. <z-navbar title="处理预定" back>
  4. <view slot="right" @click="submit">保存</view>
  5. </z-navbar>
  6. <w-picker mode="date" startYear="2000" endYear="2100" v-model="info.alertDate" :current="true" fields="day" @confirm="onConfirm($event)"
  7. @cancel="onCancel" :disabled-after="false" ref="date"></w-picker>
  8. <z-card class="mt-30 ptb-10">
  9. <z-form :model="info" :rules="rules" ref="info">
  10. <z-form-item height="100rpx" label="客户姓名" showline :labelStyle="{'color':'#ccc'}">
  11. <z-text v-model="customName" placeholder="" disabled textColor="#ccc"></z-text>
  12. </z-form-item>
  13. <z-form-item height="100rpx" label="关闭提醒" showline>
  14. <switch :checked="switchAlert" @change="changeSwitchAlert" />
  15. </z-form-item>
  16. <z-form-item height="100rpx" label="下次提醒日期" v-show="!switchAlert" prop="alertDate" showline arrow :required="!switchAlert"
  17. dynamic>
  18. <z-text v-model="info.alertDate" placeholder="请选择下次提醒时间" @click="chooseDate"></z-text>
  19. </z-form-item>
  20. <z-form-item label="备注信息" prop="remark" labelPos="top" :required="!switchAlert" dynamic>
  21. <textarea class="textarea" v-model="info.remark" placeholder="请输入备注信息" maxlength="512" auto-height></textarea>
  22. </z-form-item>
  23. </z-form>
  24. </z-card>
  25. <u-toast ref="uToast"></u-toast>
  26. </view>
  27. </template>
  28. <script>
  29. const app = getApp({
  30. allowDefault: true
  31. });
  32. export default {
  33. data() {
  34. return {
  35. id: '',
  36. customName: '',
  37. info: {
  38. alertDate: '',
  39. remark: ''
  40. },
  41. rules: {},
  42. switchAlert: true,
  43. orderAlertDaysBefore:0,
  44. orderData:''
  45. };
  46. },
  47. onLoad(option) {
  48. console.log(option)
  49. this.id = option.id;
  50. this.orderDate=option.orderDate;
  51. this.customName = option.customName;
  52. this.getorderalertTime();
  53. },
  54. methods: {
  55. getorderalertTime() {
  56. //app/config/baseByStoreId/
  57. this.$axios.get('app/config/baseByStoreId/' + uni.getStorageSync('storeId')).then(res => {
  58. console.log('预定提醒前', res.data.orderAlertDaysBefore, '天')
  59. console.log(res.data, res.data.orderAlertDaysBefore)
  60. this.orderAlertDaysBefore = Number(res.data.orderAlertDaysBefore) || 0;
  61. }).catch(err => {
  62. this.$refs.uToast.error(err.msg);
  63. })
  64. },
  65. chooseDate() {
  66. this.$refs.date.show();
  67. },
  68. onConfirm(e) {
  69. console.log(e)
  70. this.$set(this.info, 'alertDate', e.value)
  71. },
  72. onCancel() {
  73. console.log(this.$refs.date.value, this.$refs.date.pickVal)
  74. },
  75. changeSwitchAlert(e) {
  76. this.switchAlert = e.detail.value;
  77. if (this.switchAlert) {
  78. this.$set(this.info, 'alertDate', null)
  79. } else {
  80. var orderDate = this.orderDate;
  81. var time = new Date(new Date(orderDate).getTime() - this.orderAlertDaysBefore * 24 * 60 * 60 * 1000)
  82. console.log(new Date(orderDate).getTime() ,time)
  83. var month = time.getMonth() + 1,
  84. day = time.getDate();
  85. if (time.getTime() < new Date(this.$Date.getDayDate().date).getTime()) {
  86. this.$set(this.info, 'alertDate', null);
  87. } else {
  88. this.$set(this.info, 'alertDate', time.getFullYear() + '-' + (month < 10 ? ('0' + month) : month) + '-' + (
  89. day < 10 ? ('0' + day) : day))
  90. }
  91. }
  92. },
  93. submit() {
  94. this.$refs.info.validate(val => {
  95. console.log(val)
  96. if (val) {
  97. //app
  98. this.$axios.post('app/order/orderFollowAdd', {
  99. "orderId": this.id,
  100. "alertDate": this.info.alertDate,
  101. "remark": this.info.remark
  102. }).then(res => {
  103. this.$refs.uToast.success('处理咨询成功!');
  104. uni.navigateBack({
  105. delta: 1
  106. });
  107. }).catch(err => {
  108. this.$refs.uToast.error(err.msg);
  109. })
  110. } else {
  111. this.$refs.uToast.error('表单填写有误');
  112. }
  113. })
  114. }
  115. }
  116. }
  117. </script>
  118. <style scoped lang="scss">
  119. .textarea {
  120. font-size: 28rpx;
  121. min-height: 180rpx;
  122. padding-bottom: 20rpx;
  123. width: 100%;
  124. }
  125. </style>