You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

form.vue 9.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. <template>
  2. <!-- <navBar title="补办ETC卡"></navBar>
  3. -->
  4. <view class="oderPage">
  5. <view class="addr-box">
  6. <view class="addr-box-left">
  7. <view class="text-image"> 林 </view>
  8. <view class="content">
  9. <view class="">
  10. <text class="item1">林成</text>
  11. <text class="item2">18227756455</text>
  12. <text class="item3">默认</text>
  13. </view>
  14. <view class=""> 贵州省 昆明市 丽华区 XXX街道XXXXX路 201号 </view>
  15. </view>
  16. </view>
  17. <view class="edit">
  18. <image :src="`${$imgUrl}applyCard/edit.png`" mode=""></image>
  19. </view>
  20. </view>
  21. <u-form :model="form" ref="myForm" :error-type="errorType">
  22. <view class="from">
  23. <u-form-item prop="cardState">
  24. <view class="from_item">
  25. <text><text style="color: red">*</text>是否寄回设备:</text>
  26. <u-radio-group v-model="form.cardState">
  27. <u-radio
  28. :customStyle="{ marginBottom: '8px' }"
  29. activeColor="#2CE242"
  30. v-for="(item, index) in radiolist1"
  31. :key="index"
  32. :label="item.disabled"
  33. :name="item.name"
  34. @change="radioChange"
  35. >
  36. {{ item.name }}
  37. </u-radio>
  38. </u-radio-group>
  39. </view>
  40. </u-form-item>
  41. <u-form-item prop="logistics" v-if="form.cardState == '寄回'">
  42. <view class="from_item">
  43. <text><text style="color: red">*</text>退货物流公司:</text>
  44. <view style="display: flex" @click="showPicker">
  45. <u-input
  46. v-model="form.logistics"
  47. class="input"
  48. disabled
  49. placeholder="请选择"
  50. />
  51. <u-icon name="arrow-right" style="margin-left: 10px"></u-icon>
  52. </view>
  53. </view>
  54. </u-form-item>
  55. <u-form-item prop="returnNum" v-if="form.cardState == '寄回'">
  56. <view class="from_item">
  57. <text><text style="color: red"></text>退货单号:</text>
  58. <u-input v-model="form.returnNum" class="input" />
  59. </view>
  60. </u-form-item>
  61. <u-form-item prop="remark">
  62. <view class="from_item1">
  63. <text><text style="color: red">*</text>补卡原因:</text>
  64. <u-input
  65. v-model="form.remark"
  66. type="textarea"
  67. class="textarea"
  68. placeholder="请输入补卡原因,限制50字以内。"
  69. maxlength="50"
  70. />
  71. <!-- <textarea name="" id="" placeholder="请输入补卡原因,限制50字以内。"></textarea> -->
  72. </view>
  73. </u-form-item>
  74. </view>
  75. </u-form>
  76. <!-- 物流弹窗 -->
  77. <view>
  78. <!-- 物流 -->
  79. <u-select
  80. v-model="show"
  81. mode="single-column"
  82. :list="list"
  83. @confirm="confirm"
  84. ></u-select>
  85. </view>
  86. <button class="submit" @click="submit">下一步</button>
  87. </view>
  88. </template>
  89. <script setup lang="ts">
  90. import navBar from "../ETCcancellation/components/nav-bar.vue";
  91. import { reactive, ref } from "vue";
  92. import { onLoad, onShow, onReady } from "@dcloudio/uni-app";
  93. import { navTo, checkStr } from "@/utils/utils";
  94. import { request } from "../../utils/network/request.js";
  95. import { getLogistics } from "../../utils/network/api.js";
  96. import { stringToJson } from "../../utils/network/encryption.js";
  97. const list = reactive([]); //物流数据
  98. const form = reactive({
  99. cardState: "",
  100. logistics: "",
  101. returnNum: "",
  102. remark: "",
  103. });
  104. // 验证规则
  105. const rules = {
  106. cardState: [
  107. {
  108. required: true,
  109. message: "请选择",
  110. trigger: ["change", "blur"],
  111. },
  112. ],
  113. logistics: [
  114. {
  115. required: true,
  116. message: "请选择",
  117. trigger: ["change", "blur"],
  118. },
  119. ],
  120. returnNum: [
  121. {
  122. required: true,
  123. message: "请输入",
  124. trigger: ["change", "blur"],
  125. },
  126. ],
  127. remark: [
  128. {
  129. required: true,
  130. message: "请输入",
  131. trigger: ["change", "blur"],
  132. },
  133. ],
  134. };
  135. // 验证提示类型(toast要版本为1.3.5才支持)
  136. const errorType = ["message", "border-bottom", "toast"];
  137. // 设置验证规则
  138. const myForm = ref(null);
  139. onReady(() => {
  140. myForm.value.setRules(rules);
  141. });
  142. // 单选数据列表
  143. const radiolist1 = reactive([
  144. {
  145. name: "寄回",
  146. disabled: false,
  147. },
  148. {
  149. name: "不寄回",
  150. disabled: false,
  151. },
  152. ]);
  153. // 单选
  154. const radioChange = (n) => {
  155. console.log("radioChange", n);
  156. };
  157. let show = ref(false);
  158. // 打开物流先择器
  159. const showPicker = function () {
  160. show.value = true;
  161. };
  162. const confirm = (e) => {
  163. form.logistics = e[0].value;
  164. console.log(e[0].value);
  165. };
  166. onLoad(() => {
  167. getexpresslist();
  168. });
  169. const getexpresslist = () => {
  170. //参数说明
  171. let options = {
  172. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  173. data: {
  174. // opId: getItem("openId"),
  175. // source: "WECHAT",
  176. // tabIndex: "0",
  177. }, //请求参数
  178. method: "POST", //提交方式(默认POST)
  179. showLoading: true, //是否显示加载中(默认显示)
  180. };
  181. //调用方式
  182. request(getLogistics, options)
  183. .then((res) => {
  184. // stringToJson(res.bizContent)
  185. stringToJson(res.bizContent).forEach((item) => {
  186. list.push({
  187. value: item,
  188. label: item,
  189. });
  190. });
  191. })
  192. .catch((err) => {
  193. console.log(err);
  194. });
  195. };
  196. const submit = () => {
  197. myForm.value.validate((valid) => {
  198. console.log(valid);
  199. if (valid) {
  200. console.log("验证通过", form);
  201. wx.showModal({
  202. title: "模拟状况",
  203. content: "",
  204. cancelText: "记账卡",
  205. confirmText: "储蓄卡",
  206. success: function (res) {
  207. if (res.confirm) {
  208. console.log("用户点击确定");
  209. navTo("/after-sale/replace-equipment/pay-page");
  210. } else if (res.cancel) {
  211. console.log("用户点击取消");
  212. navTo("/after-sale/replace-equipment/cancellation-contract");
  213. }
  214. },
  215. });
  216. } else {
  217. console.log("验证未通过");
  218. }
  219. });
  220. };
  221. </script>
  222. <style>
  223. page {
  224. width: 100%;
  225. height: 100%;
  226. display: flex;
  227. flex-direction: column;
  228. background-color: #f3f3f3;
  229. }
  230. </style>
  231. <style lang="scss" scoped>
  232. .oderPage {
  233. flex: 1;
  234. width: 100%;
  235. .addr-box {
  236. margin-top: 20rpx;
  237. display: flex;
  238. background: #fff;
  239. padding: 30rpx;
  240. justify-content: space-between;
  241. align-items: center;
  242. .addr-box-left {
  243. display: flex;
  244. .text-image {
  245. width: 68rpx;
  246. height: 68rpx;
  247. background: #00b38b;
  248. border-radius: 50%;
  249. text-align: center;
  250. font-size: 26rpx;
  251. font-family: Microsoft YaHei;
  252. font-weight: 400;
  253. color: #ffffff;
  254. line-height: 68rpx;
  255. margin-right: 30rpx;
  256. }
  257. .content {
  258. view {
  259. font-size: 26rpx;
  260. font-family: Microsoft YaHei;
  261. font-weight: 400;
  262. color: #333333;
  263. .item1 {
  264. font-size: 30rpx;
  265. font-family: Microsoft YaHei;
  266. font-weight: 400;
  267. color: #333333;
  268. }
  269. .item2 {
  270. font-size: 24rpx;
  271. font-family: Microsoft YaHei;
  272. font-weight: 400;
  273. color: #999999;
  274. margin-left: 10rpx;
  275. }
  276. .item3 {
  277. width: 71rpx;
  278. height: 37rpx;
  279. background: #ffffff;
  280. border: 1px solid #ff8000;
  281. border-radius: 6rpx;
  282. font-size: 22rpx;
  283. font-family: Microsoft YaHei;
  284. font-weight: 400;
  285. color: #ff8000;
  286. padding: 3rpx 6rpx;
  287. margin-left: 10rpx;
  288. }
  289. }
  290. }
  291. }
  292. .edit {
  293. image {
  294. width: 50rpx;
  295. height: 50rpx;
  296. }
  297. }
  298. }
  299. .from {
  300. background-color: #fff;
  301. margin-top: 30rpx;
  302. padding: 0 30rpx;
  303. ::v-deep .u-form-item {
  304. padding: 0;
  305. line-height: normal;
  306. .u-form-item__message {
  307. margin-bottom: 12rpx;
  308. }
  309. }
  310. .from_item {
  311. display: flex;
  312. flex-wrap: nowrap;
  313. justify-content: space-between;
  314. align-items: center;
  315. height: 80rpx;
  316. border-bottom: 1rpx solid #dcdcdc;
  317. .btn {
  318. font-size: 24rpx;
  319. font-family: Microsoft YaHei;
  320. font-weight: 400;
  321. color: #ffffff;
  322. background: #00b38b;
  323. border-radius: 10rpx;
  324. padding: 10rpx 15rpx;
  325. }
  326. ::v-deep .input {
  327. text-align: left;
  328. flex: 1;
  329. input {
  330. text-align: left;
  331. }
  332. }
  333. }
  334. .from_item1 {
  335. display: flex;
  336. flex-wrap: nowrap;
  337. flex-direction: column;
  338. justify-content: space-between;
  339. padding: 30rpx 0;
  340. border-bottom: #dcdcdc 1px solid;
  341. input {
  342. text-align: right;
  343. }
  344. .textarea {
  345. background-color: #f1f1f1;
  346. width: 100%;
  347. border-radius: 20rpx;
  348. margin-top: 10rpx;
  349. text-indent: 1rem;
  350. height: 180rpx;
  351. padding: 20rpx;
  352. box-sizing: border-box;
  353. }
  354. }
  355. }
  356. }
  357. .submit {
  358. width: 670rpx;
  359. height: 80rpx;
  360. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  361. box-shadow: 0rpx 4rpx 11rpx 1rpx rgba(223, 223, 223, 0.5);
  362. border-radius: 40rpx;
  363. font-size: 32rpx;
  364. font-family: Microsoft YaHei;
  365. font-weight: 400;
  366. color: #ffffff;
  367. line-height: 80rpx;
  368. margin-top: 60rpx;
  369. }
  370. </style>