kuaiDiForm.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <view class="kuaiDiForm">
  3. <NavHeader :bind-click="goBack">
  4. <template #body>
  5. <view class="defaultBody">
  6. {{ option.standing == "Send" ? "寄件人信息" : "收件人信息" }}
  7. </view>
  8. </template>
  9. </NavHeader>
  10. <view class="tui-modal-custom">
  11. <TuiForm ref="form">
  12. <TuiInput v-model="formData.name" label="姓名" placeholder="请输入姓名" clearable required></TuiInput>
  13. <TuiInput v-model="formData.mobile" label="手机号" :line-left="false" placeholder="请输入手机号" clearable required>
  14. </TuiInput>
  15. <TuiInput
  16. v-model="formData.area" label="地址" class="activeSelect" disabled
  17. :line-left="false" placeholder="选择地址"
  18. required @click="getArea"
  19. >
  20. <template #right>
  21. <image style="width: 30rpx;height: 30rpx" src="./image/youjiantou.png" mode=""></image>
  22. </template>
  23. </TuiInput>
  24. <TuiInput v-model="formData.detailedArea" label="详细地址" :line-left="false" placeholder="请输入详细地址" clearable>
  25. </TuiInput>
  26. </TuiForm>
  27. <view class="submitView">
  28. <!-- <tui-button width="200rpx" height="72rpx" :size="28" type="primary" shape="circle"
  29. @click="modal = false;" plain>取消</tui-button> -->
  30. <tui-button width="500rpx" height="72rpx" :size="28" type="primary" shape="circle" @click="submit">
  31. 确定
  32. </tui-button>
  33. </view>
  34. </view>
  35. <TuiPicker :show="addresSelect" :layer="3" :picker-data="addresData" :params="1" @hide="hide" @change="change">
  36. </TuiPicker>
  37. </view>
  38. </template>
  39. <script>
  40. import cityData from './picker.city.js' // 地址选择组件的数据
  41. import tuiPicker from '@/components/thorui/tui-picker/tui-picker.vue'
  42. import tuiForm from '@/components/thorui/tui-form/tui-form.vue'
  43. import tuiInput from '@/components/thorui/tui-input/tui-input.vue'
  44. // import tuiModal from "@/components/thorui/tui-modal/tui-modal.vue"
  45. import NavHeader from './components/header.vue' // 头部导航栏组件
  46. export default {
  47. components: {
  48. NavHeader,
  49. // tuiModal,
  50. TuiForm: tuiForm,
  51. TuiInput: tuiInput,
  52. TuiPicker: tuiPicker
  53. },
  54. data() {
  55. return {
  56. option: '',
  57. formData: {
  58. area: '',
  59. detailedArea: '',
  60. name: '',
  61. mobile: '',
  62. standing: ''
  63. },
  64. rules: [{
  65. name: 'mobile',
  66. rule: ['required', 'isMobile'],
  67. msg: ['请输入手机号', '请输入正确的手机号']
  68. }, {
  69. name: 'name',
  70. rule: [ 'required' ],
  71. msg: [ '请输入名字' ]
  72. }, {
  73. name: 'area',
  74. rule: [ 'required' ],
  75. msg: [ '请选择地址' ]
  76. }, {
  77. name: 'detailedArea',
  78. rule: ['required', 'isMobile'],
  79. msg: [ '请补充详细地址' ]
  80. }],
  81. // modal: false,
  82. addresSelect: false,
  83. addresData: cityData
  84. }
  85. },
  86. onLoad(option) {
  87. if (!option.standing) {
  88. uni.navigateTo({
  89. url: '/pages/index/convenient-services/kuai-di/DeliveryExpress'
  90. })
  91. }
  92. this.option = option
  93. this.formData.standing = option.standing
  94. },
  95. methods: {
  96. goBack() {
  97. uni.navigateBack()
  98. },
  99. // 开启地址选择器
  100. getArea() {
  101. this.addresSelect = true
  102. },
  103. // 修改地址选择数据
  104. change(e) {
  105. this.formData.area = e.result
  106. },
  107. // 关闭地址选择器
  108. hide(e) {
  109. this.addresSelect = false
  110. },
  111. // 将用户的表单数据存入本地
  112. submit() {
  113. if (!this.$refs.form) return
  114. this.$refs.form.validate(this.formData, this.rules).then((res) => {
  115. // console.log(this.formData)
  116. uni.setStorage({
  117. key: `UserExpressInfo${this.option.standing}`,
  118. data: this.formData,
  119. success() {
  120. console.log('success')
  121. uni.navigateBack()
  122. }
  123. })
  124. // uni.navigateTo({
  125. // url: `/pages/index/convenient-services/kuai-di/DeliveryExpress?standingForm=${JSON.stringify(this.formData)}`
  126. // })
  127. // console.log('校验通过!')
  128. // this.tui.toast 等api 参考 【快手上手】文档使用
  129. // this.tui.toast('校验通过!')
  130. })
  131. }
  132. }
  133. }
  134. </script>
  135. <style lang="scss" scoped>
  136. .activeSelect:active {
  137. background: none;
  138. }
  139. .defaultBody {
  140. position: absolute;
  141. left: 50%;
  142. transform: translateX(-50%);
  143. font-size: 34rpx;
  144. color: white;
  145. font-weight: 550;
  146. }
  147. .tui-modal-custom {
  148. margin-top: 88rpx;
  149. box-sizing: border-box;
  150. padding: 20rpx;
  151. }
  152. .submitView {
  153. margin-top: 30rpx;
  154. display: flex;
  155. justify-content: center;
  156. }
  157. </style>