createOrder.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <ay-container>
  3. <ayb-station type="2" :stationInfo="data.stationInfo" />
  4. <div class="section">本次加气驾驶员</div>
  5. <div class="chunk">
  6. <div class="center justify-start">
  7. <image class="personal" :src="store.user.userInfo.head_url" mode="scaleToFill" />
  8. <div>
  9. <div class="p-fz">{{ store.user.userInfo.user_name }}</div>
  10. <div class="mt-spacd2 s-fz">{{ store.user.userInfo.mobileDes }}</div>
  11. </div>
  12. </div>
  13. </div>
  14. <div class="station">
  15. <div class="section">本次加气量(公斤)</div>
  16. <uni-easyinput
  17. v-model="data.gasQty"
  18. type="digit"
  19. placeholder="请输入"
  20. focus
  21. @input="methods.input"
  22. @confirm="methods.confirm"
  23. />
  24. </div>
  25. <div class="btns">
  26. <button
  27. type="primary"
  28. @click="methods.confirm"
  29. :loading="store.webapi.pay.add.ing"
  30. :disabled="store.webapi.pay.add.ios"
  31. >
  32. 确定
  33. </button>
  34. </div>
  35. </ay-container>
  36. </template>
  37. <script lang="ts" setup>
  38. const data = ay.initData({
  39. stationInfo: {},
  40. gasQty: '',
  41. })
  42. const gasQty = computed(() => Number(data.gasQty))
  43. const user = computed(() => store.user.userInfo)
  44. const pageConfig = computed(() => store.curPage.pageConfig)
  45. const methods = {
  46. input() {
  47. nextTick(() => {
  48. data.gasQty = data.gasQty.replace(/^\D*(\d*\.{0,1}\d{0,2}).*/, '$1')
  49. })
  50. },
  51. confirm() {
  52. if (gasQty.value <= 0) {
  53. func.native.showToast('加气量需大于零')
  54. return false
  55. }
  56. if (gasQty.value > store.common.data.preferWeight) {
  57. func.native.showToast('加气量不能超过' + store.common.data.preferWeight)
  58. return
  59. }
  60. webapi.pay
  61. .add_v2({
  62. cashierId: pageConfig.value.params.cashierId,
  63. driverId: user.value.user_id,
  64. gasQty: gasQty.value,
  65. gasstationId: pageConfig.value.params.gasstationId,
  66. createRole: 'driver', // 1 平台管理员 2 平台运营人员 filler 加气站企业管理者 cashier 收银员 carrier 物流公司管理者 driver 司机
  67. creater: user.value.user_id,
  68. createrName: user.value.user_name,
  69. })
  70. .then((res) => {
  71. ay.goPage(config.pages.order_prePay, {
  72. goPageType: enums.GoPageType.redirectTo,
  73. params: { orderId: res.orderId },
  74. })
  75. })
  76. },
  77. }
  78. ay.entrance(async (args) => {
  79. const location = await func.native.getLocation()
  80. data.stationInfo = await webapi.strategy.find_for_mini({
  81. gasstationId: pageConfig.value.params.gasstationId,
  82. longitude: location.longitude.toString(),
  83. latitude: location.latitude.toString(),
  84. })
  85. })
  86. onUnload(() => {
  87. store.webapi.pay.add.set()
  88. })
  89. </script>
  90. <style lang="scss" scoped>
  91. .personal {
  92. width: 100rpx;
  93. height: 100rpx;
  94. margin-right: $p-spac;
  95. border-radius: $p-spac;
  96. }
  97. </style>