up.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <view>
  3. <view class="mtop"><image src="../../static/my.jpg" mode="widthFix"></image></view>
  4. <view class="time">上次上报:{{ time }}</view>
  5. <view class="cn">
  6. <view class="info">
  7. <view class="form_group hr">
  8. <view class="lable">散客预约人数</view>
  9. <input type="text" placeholder="请输入散客预约人数" v-model="item.scatteredAppointment" />
  10. </view>
  11. <view class="form_group hr">
  12. <view class="lable">散客接待人数</view>
  13. <input type="number" placeholder="请输入散客接待人数" v-model="item.scatteredReception" />
  14. </view>
  15. <view class="form_group hr">
  16. <view class="lable">团客预约人数</view>
  17. <input type="number" placeholder="请输入团客预约人数" v-model="item.groupAppointment" />
  18. </view>
  19. <view class="form_group hr">
  20. <view class="lable">团客接待人数</view>
  21. <input type="number" placeholder="请输入团客接待人数" v-model="item.groupReception" />
  22. </view>
  23. <view class="form_group hr">
  24. <view class="lable">销售金额(元)</view>
  25. <input type="number" placeholder="请输入销售金额" v-model="item.salesAmount" />
  26. </view>
  27. </view>
  28. <button class="btn" @click="up()">上报数据</button>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. data() {
  35. return {
  36. item: {},
  37. time: '未上报过'
  38. };
  39. },
  40. onLoad(e) {
  41. if (e.item) {
  42. let shop = JSON.parse(e.item);
  43. this.item.shopId = shop.shopId;
  44. if (shop.shopType == 1) {
  45. this.$nextTick(() => {
  46. uni.setNavigationBarTitle({
  47. title: '门店数据上报'
  48. });
  49. });
  50. }
  51. if (shop.shopType == 2) {
  52. this.$nextTick(() => {
  53. uni.setNavigationBarTitle({
  54. title: '酒店数据上报'
  55. });
  56. });
  57. }
  58. }
  59. if (uni.getStorageSync('time') != '') {
  60. this.time = this.$u.timeFrom(new Date(uni.getStorageSync('time').replace(/\-/g, '/')).getTime());
  61. }
  62. },
  63. methods: {
  64. up() {
  65. let rule = [
  66. { name: 'scatteredAppointment', checkType: 'notnull', errorMsg: '请输入散客预约人数' },
  67. { name: 'scatteredReception', checkType: 'notnull', errorMsg: '请输入散客接待人数' },
  68. { name: 'groupAppointment', checkType: 'notnull', errorMsg: '请输入团客预约人数' },
  69. { name: 'groupReception', checkType: 'notnull', errorMsg: '请输入团客接待人数' },
  70. { name: 'salesAmount', checkType: 'notnull', errorMsg: '请输入销售金额' }
  71. ];
  72. if (!this.$verify.check(this.item, rule)) {
  73. uni.showModal({ content: this.$verify.error, showCancel: false });
  74. return;
  75. }
  76. this.$http.request({
  77. method: 'POST',
  78. url: this.$http.urls.pushRecord,
  79. data: this.item,
  80. success: res => {
  81. uni.showToast({ title: '上报成功' });
  82. uni.setStorageSync('time', this.$util.getDate('time'));
  83. setTimeout(() => {
  84. uni.navigateBack();
  85. }, 700);
  86. }
  87. });
  88. }
  89. }
  90. };
  91. </script>
  92. <style lang="scss">
  93. .mtop {
  94. text-align: center;
  95. image {
  96. margin-top: 15px;
  97. width: 40%;
  98. }
  99. }
  100. .time {
  101. text-align: center;
  102. color: $dar;
  103. font-size: 13px;
  104. }
  105. .cn {
  106. padding: 15px;
  107. .info {
  108. background-color: white;
  109. border-radius: 5px;
  110. margin-top: 10px;
  111. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  112. }
  113. .btn {
  114. margin-top: 25px;
  115. }
  116. }
  117. </style>