pricate.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <view class="content">
  3. <u-form :model="form" ref="uForm" :error-type="errorType">
  4. <u-form-item label="姓名" prop="name">
  5. <u-input v-model="form.name" />
  6. </u-form-item>
  7. <u-form-item label="简介" prop="intro">
  8. <u-input v-model="form.intro" />
  9. </u-form-item>
  10. <u-form-item prop="phone">
  11. <u-field v-model="form.phone" label="手机" placeholder="请填写手机号" />
  12. </u-form-item>
  13. <u-form-item label="性别">
  14. <u-input v-model="form.sex" type="select" />
  15. </u-form-item>
  16. <u-form-item label="水果">
  17. <u-checkbox-group @change="checkboxChange">
  18. <u-checkbox v-model="item.checked" v-for="(item, index) in checkboxList" :key="index" :name="item.name">
  19. {{ item.name }}
  20. </u-checkbox>
  21. </u-checkbox-group>
  22. </u-form-item>
  23. <u-form-item label="味道">
  24. <u-radio-group v-model="radio">
  25. <u-radio v-for="(item, index) in radioList" :key="index" :name="item.name" :disabled="item.disabled">
  26. {{ item.name }}
  27. </u-radio>
  28. </u-radio-group>
  29. </u-form-item>
  30. <u-form-item label="开关">
  31. <u-switch slot="right" v-model="switchVal"></u-switch>
  32. </u-form-item>
  33. </u-form>
  34. <u-button @click="submit">提交</u-button>
  35. <u-steps :list="numList" mode="number" :current="current" active-color="#fa3534"></u-steps>
  36. <!-- <view v-if="current == 0">
  37. <view>aaa</view>
  38. <u-button type="success" @click="gostep">下一步</u-button>
  39. </view>
  40. <view v-if="current == 1">
  41. <view>cccccccccccccccccccccccccccccc</view>
  42. <u-button type="success" @click="gostep">成功按钮</u-button>
  43. </view>
  44. <view v-if="current == 2">
  45. <view>bbbb</view>
  46. <u-button type="success" @click="gostep">成功按钮</u-button>
  47. </view> -->
  48. <view v-if="numList[current]">
  49. <view>{{numList[current].shop}}</view>
  50. <u-button type="success" @click="gostep">{{numList[current].btn}}</u-button>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import {
  56. getBing
  57. } from "../../utils/service.js";
  58. export default {
  59. data() {
  60. return {
  61. errorType: ['toast'],
  62. form: {
  63. name: '',
  64. intro: '',
  65. sex: '',
  66. phone: '',
  67. },
  68. checkboxList: [{
  69. name: '苹果',
  70. checked: false,
  71. disabled: false
  72. },
  73. {
  74. name: '雪梨',
  75. checked: false,
  76. disabled: false
  77. },
  78. {
  79. name: '柠檬',
  80. checked: false,
  81. disabled: false
  82. }
  83. ],
  84. radioList: [{
  85. name: '鲜甜',
  86. disabled: false
  87. },
  88. {
  89. name: '麻辣',
  90. disabled: false
  91. }
  92. ],
  93. numList: [{
  94. name: '下单',
  95. shop: '手机',
  96. btn: '下一步'
  97. }, {
  98. name: '出库',
  99. shop: '电话',
  100. btn: '下一步'
  101. }, {
  102. name: '运输',
  103. shop: '学习机',
  104. btn: '提交'
  105. }, ],
  106. current: 0,
  107. radio: '',
  108. switchVal: false,
  109. rules: {
  110. name: [{
  111. required: true,
  112. message: '请输入姓名',
  113. // 可以单个或者同时写两个触发验证方式
  114. trigger: ['change', 'blur'],
  115. }],
  116. intro: [{
  117. min: 5,
  118. message: '简介不能少于5个字',
  119. trigger: 'change'
  120. }],
  121. phone: [{
  122. required: true,
  123. message: '请输入手机号',
  124. trigger: ['change', 'blur'],
  125. },
  126. {
  127. // 自定义验证函数,见上说明
  128. validator: (rule, value, callback) => {
  129. // 上面有说,返回true表示校验通过,返回false表示不通过
  130. // this.$u.test.mobile()就是返回true或者false的
  131. return this.$u.test.mobile(value);
  132. },
  133. message: '手机号码不正确',
  134. // 触发器可以同时用blur和change
  135. trigger: ['change', 'blur'],
  136. }
  137. ]
  138. }
  139. }
  140. },
  141. onLoad() {
  142. },
  143. onReady() {
  144. this.$refs.uForm.setRules(this.rules);
  145. },
  146. methods: {
  147. // 选中某个复选框时,由checkbox时触发
  148. checkboxChange(e) {
  149. console.log(e);
  150. },
  151. submit() {
  152. // this.$refs.uForm.validate(valid => {
  153. // if (valid) {
  154. // console.log('验证通过');
  155. // } else {
  156. // console.log('验证失败');
  157. // }
  158. // });
  159. getBing({
  160. name:'7778880105007',
  161. pwd: 'e10adc3949ba59abbe56e057f20f883e',
  162. appletsId: 'oqqAL4wZlDm8UYJFjdJljt - BoFvw'
  163. })
  164. .then(data => {
  165. console.log(data, "000000")
  166. })
  167. },
  168. gostep() {
  169. if (this.current == this.numList.length - 1) {
  170. return
  171. }
  172. console.log(this.current)
  173. this.current += 1;
  174. },
  175. // sumbitOlds() {
  176. // this.$refs.uForm.validate(valid => {
  177. // if (valid) {
  178. // console.log('验证通过');
  179. // } else {
  180. // console.log('验证失败');
  181. // }
  182. // });
  183. // },
  184. }
  185. }
  186. </script>
  187. <style scoped>
  188. /deep/ .u-form-item--left__content__label {
  189. color: red;
  190. }
  191. </style>