您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

transfer-page-sign.vue 9.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <template>
  2. <view class="content">
  3. <view><text>车牌号:</text><input placeholder="请输入车牌号" v-model="state.vehiclePlate"/></view>
  4. <view><text>车牌颜色:</text>
  5. <view style="width: 60%;">
  6. <uni-data-select style="width: 100%;" v-model="state.vehiclePlateColor" :localdata="state.colorRange" @change="changeColor"
  7. :clear="false"></uni-data-select>
  8. </view>
  9. </view>
  10. <view><text>身份证后四位:</text><input placeholder="请输入身份证后四位" v-model="state.idCard"/></view>
  11. <view><text>手机号码:</text><input placeholder="请输入手机号码" v-model="state.mobile"/></view>
  12. <view class="action">
  13. <button type="default" class="ui-btn" @click="query()">
  14. 查询
  15. </button>
  16. </view>
  17. </view>
  18. <view class="details" v-if="state.isDetails">
  19. <view><text>车牌号</text><text class="car">{{state.details['vehiclePlate']}}</text></view>
  20. <view><text>车牌颜色</text><text class="car">{{getVehiclePlateColor(state.details['vehiclePlateColor'])}}</text></view>
  21. <view><text>车主姓名</text><text class="car">{{state.details['ownerName']}}</text></view>
  22. <view v-if="state.details['handlerName']"><text>办理人</text><text class="car">{{state.details['handlerName']}}</text></view>
  23. <view><text>产品名称</text><text class="car">{{state.details['productName']}}</text></view>
  24. <view><text>权益说明</text><text class="car">{{state.details['rightsDesc']}}</text></view>
  25. <view><text>产品金额</text><text class="car">¥{{state.details['productAmount']*0.01}}</text></view>
  26. <view><text>应付金额</text><text class="car">¥{{state.details['productAmount']*0.01}}</text></view>
  27. <view class="noborder other-free">无其他费用</view>
  28. <view class="noborder yansghi">
  29. <checkbox-group @change="checkboxChange">
  30. <checkbox :checked="state.checked" style="transform: scale(0.65)" />
  31. <text class='txt'>我已阅读并同意</text>
  32. </checkbox-group>
  33. <text v-for="(item,index) in state.agreeURL" class="txt xieyi" @click="downAuthD(item)">《{{item.name}}》</text>
  34. </view>
  35. <view class="action" style="margin-bottom: 30rpx;">
  36. <button type="default" class="ui-btn" @click="savaHandle()" v-if="state.isSign">
  37. 确认办理
  38. </button>
  39. <button type="default" class="ui-btn" @click="sign()" v-else>
  40. 去签署协议
  41. </button>
  42. </view>
  43. </view>
  44. </template>
  45. <script setup lang="ts">
  46. import { reactive } from "vue";
  47. import { onLoad,onShow } from "@dcloudio/uni-app";
  48. import {
  49. navTo,hasLogin
  50. } from "@/utils/utils"
  51. import {agreementInSertOrder,contractQuery,orderQuery,accountSign,agreeOrderProdcut,envs} from "@/utils/network/api.js";
  52. import {
  53. getItem,
  54. StorageKeys,
  55. setItem
  56. } from "@/utils/storage";
  57. import {requestNew} from "@/utils/network/request.js";
  58. import { msg } from "@/utils/utils";
  59. import { vehiclePlateColorPai } from "@/datas/vehiclePlateColor.js";
  60. import {
  61. getVehiclePlateColor
  62. } from "@/datas/vehiclePlateColor";
  63. import {
  64. OrderStatus
  65. } from "@/datas/enum";
  66. const state = reactive({
  67. checked:false,
  68. agreeURL: [],
  69. agreements:[],
  70. isSign:false,
  71. colorRange:[],
  72. idCard:"",
  73. mobile:"",
  74. vehiclePlate:"",
  75. vehiclePlateColor:"",
  76. details:{},
  77. isDetails:false,
  78. orderId:""
  79. });
  80. onShow(()=>{
  81. if(state.orderId){
  82. contractRequest()
  83. }
  84. })
  85. onLoad(() => {
  86. let getColor = getItem('key')['VEHICLE_COLOR_TYPE'];
  87. for (var k = 0; k < getColor.length; k++) {
  88. let obj = {};
  89. obj['value'] = getColor[k]['code']
  90. obj['text'] = getColor[k]['name']
  91. state.colorRange.push(obj)
  92. }
  93. // 没登录情况
  94. if (!hasLogin()) {
  95. navTo( `/login/login?back=1`)
  96. }else{
  97. }
  98. })
  99. const query=()=>{
  100. if(!state.vehiclePlate){
  101. msg('请输入车牌号')
  102. return;
  103. }
  104. if(!state.vehiclePlateColor){
  105. msg('请选择车牌颜色')
  106. return;
  107. }
  108. if(!state.idCard){
  109. msg('请输入身份证后四位')
  110. return;
  111. }
  112. if(!state.mobile){
  113. msg('请输入手机号码')
  114. return;
  115. }
  116. const options = {
  117. type: 2,
  118. data: {
  119. vehiclePlate: state.vehiclePlate,
  120. vehiclePlateColor: state.vehiclePlateColor,
  121. idCard: state.idCard,
  122. mobile: state.mobile,
  123. },
  124. method: "POST",
  125. showLoading: true,
  126. };
  127. requestNew(orderQuery, options).then((res) => {
  128. console.log("擦寻",res)
  129. state.details=res
  130. state.isDetails=true
  131. state.orderId=res.orderNo
  132. queryAgreement()
  133. })
  134. }
  135. const savaHandle=()=>{
  136. if (state.checked) {
  137. if(state.details['orderStatus']!= OrderStatus.已取消){
  138. // 去支付
  139. if(state.details['orderStep']==OrderStatus['完成车辆信息上传/待支付'] || state.details['orderStep']==OrderStatus['待支付2']){
  140. agreementConfirm().then((value) => {
  141. console.log("协议确认", value)
  142. let vehicleId=state.details['vehiclePlate']+"_"+state.details['vehiclePlateColor']
  143. let isValueCard=1
  144. // qtSign 有数据 去签约
  145. if(state.details['qtSign']==0 || state.details['qtSign']==1){
  146. isValueCard=2
  147. }else{
  148. isValueCard=1
  149. }
  150. navTo(`/subpackage/orders/order_payment?orderId=${state.orderId}&&isValueCard=${isValueCard}&vehicleId=${vehicleId}`);
  151. })
  152. }else if(state.details['orderStep'] == OrderStatus['已支付/待签约']){
  153. // 去签约
  154. navTo(`/subpackage/orders/release-products?orderId=${state.orderId}`);
  155. }
  156. }
  157. } else {
  158. msg("请勾选协议");
  159. }
  160. }
  161. // 协议确认接口
  162. const agreementConfirm = () => {
  163. const options = {
  164. type: 2,
  165. data: {
  166. orderId: state.orderId,
  167. protocol: state.checked ? 1 : 0,
  168. agreements: state.agreements
  169. },
  170. method: "POST",
  171. showLoading: true,
  172. };
  173. return new Promise(async (resolve, reject) => {
  174. const res = await requestNew(agreeOrderProdcut, options);
  175. const data = res;
  176. console.log("确认协议", data)
  177. resolve(data);
  178. }).catch((error) => {
  179. reject(error);
  180. });
  181. };
  182. const checkboxChange = (e) => {
  183. state.checked = !state.checked;
  184. console.log(state.checked);
  185. };
  186. // 查协议
  187. const queryAgreement = () => {
  188. const options = {
  189. type: 2,
  190. data: {
  191. orderId: state.orderId, //订单编号
  192. status: 1
  193. },
  194. method: "POST",
  195. showLoading: true,
  196. };
  197. requestNew(agreementInSertOrder, options).then((res) => {
  198. let data = res;
  199. let supAgreeArr = data.data
  200. // 每次点击先清空
  201. state.agreeURL=[]
  202. console.log("data==", supAgreeArr)
  203. for (var m = 0; m < supAgreeArr.length; m++) {
  204. let obj = {}
  205. obj['name'] = supAgreeArr[m]['name']
  206. for (var k = 0; k < supAgreeArr[m]['address'].length; k++) {
  207. state.agreements.push(supAgreeArr[m]['address'][k]['id'])
  208. obj['url'] = envs[process.env.NODE_ENV].baseUrl + supAgreeArr[m]['address'][k]['url']
  209. state.agreeURL.push(obj)
  210. }
  211. }
  212. contractRequest()
  213. console.log("查协议", state.agreeURL)
  214. });
  215. }
  216. const downAuthD = (item) => {
  217. console.log('=======123', item)
  218. console.log("uni.env.USER_DATA_PATH '", uni.env.USER_DATA_PATH + '/' + '产品协议.docx')
  219. // 文件后缀截取
  220. var index = item.url.lastIndexOf("\.");
  221. let fileType = item.url.substring(index + 1, item.url.length);
  222. console.log("fileType", fileType)
  223. uni.downloadFile({
  224. url: item.url,
  225. filePath: uni.env.USER_DATA_PATH + '/' + item.name + '.' + fileType,
  226. success(res) {
  227. const filePath = res.filePath
  228. console.log("filePath", filePath)
  229. uni.openDocument({
  230. filePath: filePath,
  231. fileType: fileType,
  232. showMenu: true, //关键点
  233. success: function (res) {
  234. },
  235. fail: function (err) {
  236. msg("打开文档失败");
  237. }
  238. });
  239. },
  240. fail: function (err) {
  241. msg("下载文档失败");
  242. console.log("err", err)
  243. },
  244. complete(res) {
  245. }
  246. })
  247. }
  248. // 查询是否签署协议
  249. const contractRequest=()=>{
  250. const options = {
  251. type: 2,
  252. data: {
  253. orderId: state.orderId, //订单编号
  254. },
  255. method: "POST",
  256. showLoading: true,
  257. };
  258. requestNew(contractQuery, options).then((res) => {
  259. if(res.contractState==1){
  260. state.isSign=true
  261. }else{
  262. state.isSign=false
  263. }
  264. console.log("查询是否签署协议", res)
  265. });
  266. }
  267. // 去签署协议
  268. const sign=()=>{
  269. const options = {
  270. type: 2,
  271. data: {
  272. orderId: state.orderId, //订单编号
  273. },
  274. method: "POST",
  275. showLoading: true,
  276. };
  277. requestNew(accountSign, options).then((res) => {
  278. navTo(`/subpackage/orders/webView?url=${res.shortUrl}`)
  279. console.log("去签署协议", res.shortUrl)
  280. });
  281. }
  282. const changeColor = (e) => {
  283. state.vehiclePlateColor = e
  284. console.log(e)
  285. }
  286. </script>
  287. <style scoped lang="scss">
  288. .content{
  289. font-size: 30rpx;
  290. background-color: white;
  291. box-sizing: border-box;
  292. padding: 20rpx 30rpx 40rpx 30rpx;
  293. view{
  294. display: flex;
  295. margin-bottom: 4rpx;
  296. align-items: center;
  297. height: 76rpx;
  298. text{
  299. width: 22%;
  300. }
  301. input{
  302. border:1rpx solid #ccc ;
  303. margin-left: 20rpx;
  304. padding: 6rpx 10rpx;
  305. width: 60%;
  306. border-radius: 5rpx;
  307. box-sizing: border-box;
  308. height: 60rpx;
  309. }
  310. }
  311. }
  312. .details{
  313. font-size: 30rpx;
  314. background-color: white;
  315. box-sizing: border-box;
  316. padding: 20rpx 30rpx;
  317. margin-top: 30rpx;
  318. view{
  319. border-bottom: 1rpx solid #ccc;
  320. height: 62rpx;
  321. line-height: 62rpx;
  322. display: flex;
  323. justify-content: space-between;
  324. .car{
  325. font-weight: bold;
  326. }
  327. }
  328. .noborder{
  329. border-bottom: none;
  330. }
  331. .other-free{
  332. display: flex;
  333. justify-content: flex-end;
  334. }
  335. .sure{
  336. margin: 30rpx 0;
  337. }
  338. }
  339. .action{
  340. margin-top: 30rpx;
  341. }
  342. ::v-deep .uni-select{
  343. margin-left: 20rpx;
  344. box-sizing: border-box !important;
  345. padding-left: 10rpx !important;
  346. border:1rpx solid #ccc ;
  347. height: 56rpx;
  348. }
  349. ::v-deep .uni-select__input-text{
  350. font-size: 30rpx !important;
  351. }
  352. .yansghi{
  353. height: auto !important;
  354. line-height: normal !important;
  355. display: flex !important;
  356. justify-content: flex-start !important;
  357. flex-shrink: 1 !important;
  358. flex-wrap: wrap !important;
  359. align-items: center !important;
  360. }
  361. </style>