index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. <template>
  2. <el-dialog class="address" :show-close="true" center v-model="updateFlag" title="修改地址">
  3. <el-form ref="loginFormRef" :model="addressState" :rules="rules">
  4. <div class="address-content">
  5. <div class="address-view">
  6. <div class="star">*</div>
  7. <div>所在地区:</div>
  8. <div>
  9. <el-form-item prop="address">
  10. <el-cascader :props="props" :options=area.arr v-model="addressState.address" @change="handleChange" clearable>
  11. </el-cascader>
  12. </el-form-item>
  13. </div>
  14. </div>
  15. <div class="address-view" style="margin-top: 20px">
  16. <div class="star">*</div>
  17. <div>详细地址:</div>
  18. <div>
  19. <el-form-item prop="addressDetail">
  20. <el-input
  21. :rows="5"
  22. type="textarea"
  23. v-model.trim="addressState.addressDetail"
  24. ></el-input>
  25. </el-form-item>
  26. </div>
  27. </div>
  28. <div class="address-view" style="margin-left: 16px">
  29. <div class="star">*</div>
  30. <div >收货人:</div>
  31. <div>
  32. <el-form-item prop="userName">
  33. <el-input
  34. v-model.trim="addressState.userName"
  35. ></el-input>
  36. </el-form-item>
  37. </div>
  38. </div>
  39. <div class="address-view">
  40. <div class="star">*</div>
  41. <div>联系电话:</div>
  42. <div>
  43. <el-form-item prop="userPhone">
  44. <el-input
  45. v-model.trim="addressState.userPhone"
  46. ></el-input>
  47. </el-form-item>
  48. </div>
  49. </div>
  50. <div class="address-view">
  51. <div class="star">*</div>
  52. <div>默认地址:</div>
  53. <div>
  54. <el-switch v-model="value1" />
  55. </div>
  56. </div>
  57. </div>
  58. <div class="button-s">
  59. <div class="style" @click="updateFlag=false">取消</div>
  60. <div class="style colors" @click="updateTap()">确认修改</div>
  61. </div>
  62. </el-form>
  63. </el-dialog>
  64. <el-dialog class="address" :show-close="true" center v-model="addressFlag" title="添加地址">
  65. <el-form ref="loginFormRef" :model="addressState" :rules="rules">
  66. <div class="address-content">
  67. <div class="address-view">
  68. <div class="star">*</div>
  69. <div>所在地区:</div>
  70. <div>
  71. <el-form-item prop="address">
  72. <el-cascader :props="props" :options=area.arr v-model="addressState.address" @change="handleChange" clearable>
  73. </el-cascader>
  74. </el-form-item>
  75. </div>
  76. </div>
  77. <div class="address-view" style="margin-top: 20px">
  78. <div class="star">*</div>
  79. <div>详细地址:</div>
  80. <div>
  81. <el-form-item prop="addressDetail">
  82. <el-input
  83. :rows="5"
  84. type="textarea"
  85. v-model.trim="addressState.addressDetail"
  86. ></el-input>
  87. </el-form-item>
  88. </div>
  89. </div>
  90. <div class="address-view" style="margin-left: 16px">
  91. <div class="star">*</div>
  92. <div >收货人:</div>
  93. <div>
  94. <el-form-item prop="userName">
  95. <el-input
  96. v-model.trim="addressState.userName"
  97. ></el-input>
  98. </el-form-item>
  99. </div>
  100. </div>
  101. <div class="address-view">
  102. <div class="star">*</div>
  103. <div>联系电话:</div>
  104. <div>
  105. <el-form-item prop="userPhone">
  106. <el-input
  107. v-model.trim="addressState.userPhone"
  108. ></el-input>
  109. </el-form-item>
  110. </div>
  111. </div>
  112. <div class="address-view">
  113. <div class="star">*</div>
  114. <div>默认地址:</div>
  115. <div>
  116. <el-switch v-model="value1" />
  117. </div>
  118. </div>
  119. </div>
  120. <div class="button-s">
  121. <div class="style" @click="addressFlag=false">取消</div>
  122. <div class="style colors" @click="addressTap()">确认添加</div>
  123. </div>
  124. </el-form>
  125. </el-dialog>
  126. <div class="login-wrapper">
  127. <div>
  128. <indexHeaders/>
  129. </div>
  130. <div class="register">
  131. <div class="register-left">
  132. <UserNav :navIndexs="2"/>
  133. </div>
  134. <div class="register-content">
  135. <div class="collect-tops">
  136. <div class="icons">
  137. <img src="http://screen.zhousi.hdlkeji.com/aksdbn/img/address-icon.png">
  138. </div>
  139. <div style="flex: 1">收货地址</div>
  140. <div class="add" @click="addressFlag=true;addClick()">新增</div>
  141. </div>
  142. <div class="tops">
  143. <div class="tops-order-text ">姓名</div>
  144. <div class="tops-order-text">手机号</div>
  145. <div class="tops-order-text">收货地址</div>
  146. <div class="tops-order-text">操作</div>
  147. </div>
  148. <div class="news-no" v-if="addressList.arr==''">
  149. <img src="http://screen.zhousi.hdlkeji.com/aksdbn/img/news-no-bg3.png">
  150. <div>暂无相关信息</div>
  151. </div>
  152. <div class="list" v-for="item in addressList.arr">
  153. <div class="evaluate-goods">
  154. <div class="order-info flexs overflow1">
  155. {{ item.name }}
  156. </div>
  157. <div class="order-money flexs color-s" >{{ item.mobile }}</div>
  158. <div class="order-status flexs" >{{ item.full_address }}</div>
  159. <div class="address-oper">
  160. <div @click="update(item)">修改</div>
  161. <div @click="del(item.id)">删除</div>
  162. <div @click="updateAddress(item)">设为默认</div>
  163. </div>
  164. </div>
  165. </div>
  166. </div>
  167. </div>
  168. </div>
  169. <RightSliderBar/>
  170. <Footer/>
  171. </template>
  172. <script setup>
  173. const value1=ref(false)
  174. //记录访问次数
  175. if(localStorage.getItem('USER__INFO__')){
  176. user_lsp().then((res)=>{
  177. })
  178. }
  179. import { provide, reactive, ref ,onMounted} from 'vue'
  180. import { ElMessage, ElMessageBox } from 'element-plus'
  181. import UserNav from '@/components/User/UserNav.vue'
  182. import indexHeaders from '@/components/Index/indexHeaders.vue'
  183. import LeftSliderBar from '@/components/Index/LeftSliderBar.vue'
  184. import RightSliderBar from '@/components/Index/RightSliderBar.vue'
  185. import CountDate from '@/components/Index/CountDate.vue'
  186. import Footer from '@/components/Tool/Footer.vue'
  187. import {isLogin} from "@/utils";
  188. import {useI18n} from "@/hooks/web/useI18n";
  189. import {address_list, del_address, get_area, goods_cart_del, user_address_controller, user_lsp} from "@/api/menu1";
  190. import {getStore} from "@/utils/storage";
  191. const { t } = useI18n()
  192. let addressFlag=ref(false)
  193. let updateFlag=ref(false)
  194. const guide = ref(['资讯中心'])
  195. let guideIndex =ref(0)
  196. const evaluateNav = ref(['全部订单','待付款','待收货','已完成'])
  197. let nacIndex = ref(0)
  198. let userAddress=ref('')
  199. const address = ref([])
  200. const loginFormRef=ref('')
  201. const handleChange = (label) => {
  202. userAddress.value=label[2]
  203. address.value=label
  204. console.error(label)
  205. }
  206. const addClick=()=>{
  207. addressState.address=''
  208. addressState.addressDetail=''
  209. addressState.userName=''
  210. addressState.userPhone=''
  211. userAddress.value=''
  212. value1.value=false
  213. }
  214. const update=(item)=>{
  215. // let arr=[];
  216. // arr.push(item.area)
  217. const chars = item.area.split(',');
  218. let datas=[]
  219. for(var key in chars){
  220. if(key==2){
  221. userAddress.value=chars[key]
  222. }
  223. datas.push(parseInt(chars[key]))
  224. }
  225. updateFlag.value=true
  226. addressState.address=datas
  227. addressState.addressDetail=item.address
  228. addressState.userName=item.name
  229. addressState.userPhone=item.mobile
  230. addressState.id=item.id
  231. value1.value=item.is_default==1?true:false
  232. }
  233. const props={
  234. value: 'value',
  235. label: 'label',
  236. children: 'children',
  237. }
  238. const clickTap = (index) =>{
  239. nacIndex.value=index;
  240. }
  241. const changes=(value)=>{
  242. console.error(value)
  243. }
  244. onMounted(()=>{
  245. list();
  246. })
  247. const del=(id)=>{
  248. ElMessageBox({
  249. title: '提示',
  250. message: '确认删除该地址吗?',
  251. showCancelButton: true,
  252. confirmButtonText: '确定',
  253. cancelButtonText: '取消',
  254. callback: (action) => {
  255. if (action === 'confirm') {
  256. del_address({id:id}).then((res)=>{
  257. if(res.code==1){
  258. ElMessage.success('删除地址成功')
  259. list();
  260. }else{
  261. ElMessage.error(res.msg)
  262. }
  263. })
  264. }
  265. }
  266. })
  267. }
  268. const updateAddress=(item)=> {
  269. console.log(item);
  270. const chars = item.area.split(',');
  271. let datas=[]
  272. for(var key in chars){
  273. datas.push(parseInt(chars[key]))
  274. }
  275. let data={
  276. id:item.id,
  277. name:item.name,
  278. mobile:item.mobile,
  279. address:item.address,
  280. is_default:1,
  281. city:datas[2]
  282. }
  283. user_address_controller(data).then((res)=>{
  284. if(res.code==1){
  285. ElMessage.success('默认地址修改成功')
  286. // updateFlag.value=false
  287. // addressLists();
  288. }else{
  289. ElMessage.error(res.msg)
  290. }
  291. })
  292. }
  293. const updateTap=()=>{
  294. loginFormRef.value.validate(valid => {
  295. if (!valid) {
  296. return false
  297. }else{
  298. let data={
  299. id:addressState.id,
  300. name:addressState.userName,
  301. mobile:addressState.userPhone,
  302. address:addressState.addressDetail,
  303. is_default:value1.value==true?1:0,
  304. city:userAddress.value
  305. }
  306. user_address_controller(data).then((res)=>{
  307. if(res.code==1){
  308. ElMessage.success('修改成功')
  309. updateFlag.value=false
  310. list();
  311. }else{
  312. ElMessage.error(res.msg)
  313. }
  314. })
  315. }
  316. })
  317. }
  318. const addressTap=()=>{
  319. loginFormRef.value.validate(valid => {
  320. if (!valid) {
  321. return false
  322. }else{
  323. let data={
  324. id:'',
  325. name:addressState.userName,
  326. mobile:addressState.userPhone,
  327. address:addressState.addressDetail,
  328. is_default:value1.value==true?1:0,
  329. city:userAddress.value
  330. }
  331. user_address_controller(data).then((res)=>{
  332. if(res.code==1){
  333. ElMessage.success('新增成功')
  334. addressFlag.value=false
  335. list();
  336. }else{
  337. ElMessage.error(res.msg)
  338. }
  339. })
  340. }
  341. })
  342. }
  343. const addressList=reactive({
  344. arr:[]
  345. })
  346. const list=()=>{
  347. address_list().then((res)=>{
  348. addressList.arr=res.data
  349. })
  350. }
  351. const newsList =[
  352. { id: '1', src: 'http://screen.zhousi.hdlkeji.com/aksdbn/img/goods/seckill-goods.png' ,goods: 'http://screen.zhousi.hdlkeji.com/aksdbn/img/goods/seckill-bg.png' },
  353. { id: '2', src: 'http://screen.zhousi.hdlkeji.com/aksdbn/img/goods/seckill-bg2.png' ,goods: 'http://screen.zhousi.hdlkeji.com/aksdbn/img/goods/seckill-bg.png'},
  354. { id: '3', src: 'http://screen.zhousi.hdlkeji.com/aksdbn/img/goods/seckill-bg3.png' ,goods: 'http://screen.zhousi.hdlkeji.com/aksdbn/img/goods/seckill-bg.png'}
  355. ]
  356. const addressState = reactive({
  357. address: '',
  358. addressDetail:'',
  359. userName:'',
  360. userPhone:'',
  361. id:'',
  362. })
  363. const rules = {
  364. name: [{ required: true, message: t('home.login.form.nameRequired'), trigger: 'blur' }],
  365. cardName: [{ required: true, message: t('home.login.form.cardNameRequired'), trigger: 'blur' }],
  366. cardBank: [{ required: true, message: t('home.login.form.cardBankRequired'), trigger: 'blur' }],
  367. cardNumber: [{ required: true, message: t('home.login.form.cardNumberRequired'), trigger: 'blur' }],
  368. address: [{ required: true, message: t('home.login.form.addressRequired'), trigger: 'blur' }],
  369. addressDetail: [{ required: true, message: t('home.login.form.addressDetailRequired'), trigger: 'blur' }],
  370. userName: [{ required: true, message: t('home.login.form.userNameRequireds'), trigger: 'blur' }],
  371. userPhone: [{ required: true, message: t('home.login.form.phoneRequired'), trigger: 'blur' }],
  372. }
  373. let area=reactive({
  374. arr:[]
  375. })
  376. get_area().then((res)=>{
  377. area.arr=res.data
  378. })
  379. isLogin()
  380. </script>
  381. <style lang="less" scoped >
  382. .flexs{
  383. flex:1;
  384. text-align: center;
  385. }
  386. .button-s{
  387. display: flex;
  388. justify-content: center;
  389. .colors{
  390. background-color: #3171B8!important;
  391. color: #fff!important;
  392. }
  393. .style{
  394. cursor: pointer;
  395. width: 140px;
  396. height: 30px;
  397. background: #FFFFFF;
  398. color: #3171B8;
  399. font-size: 16px;
  400. text-align: center;
  401. line-height: 30px;
  402. margin-right: 25px;
  403. border: 1px solid #3171B8;
  404. }
  405. }
  406. .address-content{
  407. padding: 0 70px;
  408. .star{
  409. color: #EE341A;
  410. margin: 0 10px 0 0px;
  411. }
  412. .address-view{
  413. display: flex;
  414. line-height: 36px;
  415. }
  416. }
  417. /deep/ .el-textarea__inner{
  418. width: 387px;
  419. }
  420. /deep/ .address-view .el-input{
  421. width: 387px;
  422. height: 36px;
  423. background: #FFFFFF;
  424. font-size: 16px;
  425. }
  426. .login-wrapper{
  427. background-color: #F7F8FA;
  428. .register{
  429. display: flex;
  430. padding: 0 260px 40px 260px;
  431. .register-content{
  432. .tops{
  433. height: 50px;
  434. background: #F0F2F5;
  435. margin: 20px 20px 0 20px;
  436. display: flex;
  437. color: #333;
  438. font-size: 16px;
  439. line-height: 50px;
  440. .tops-order-text{
  441. flex: 1;
  442. text-align: center;
  443. }
  444. .tops-order-text:nth-child(1) {
  445. flex: 0 0 170px;
  446. }
  447. .tops-order-text:nth-child(2) {
  448. flex: 0 0 200px;
  449. }
  450. }
  451. .collect-tops{
  452. .add{
  453. color: #4171B3;
  454. font-size: 16px;
  455. cursor: pointer;
  456. }
  457. display: flex;
  458. font-size: 18px;
  459. color: #333;
  460. justify-content: space-between;
  461. //border-bottom: 1px solid #f4f4f4;
  462. height: 65px;
  463. line-height: 65px;
  464. padding: 0 20px;
  465. div{
  466. margin-right: 10px;
  467. }
  468. .icons{
  469. margin-top: 8px;
  470. img{
  471. width: 29px;
  472. height: 29px;
  473. }
  474. }
  475. }
  476. .address-oper{
  477. // width: 100%;
  478. // text-align: center;
  479. color: #4171B3;
  480. font-size: 16px;
  481. display: flex;
  482. margin: 0 auto;
  483. // justify-content: center;
  484. div{
  485. margin-right: 10px;
  486. cursor: pointer;
  487. }
  488. }
  489. .evaluate-nav{
  490. display: flex;
  491. .evaluate-nav-view{
  492. cursor: pointer;
  493. padding: 0 30px;
  494. height: 50px;
  495. line-height: 50px;
  496. color: #333333;
  497. font-size: 18px;
  498. box-sizing: border-box;
  499. .line{
  500. width: 80px;
  501. margin-left: -10px;
  502. height: 5px;
  503. background: linear-gradient(270deg, #FFFFFF 0%, #4171B3 100%);
  504. border-radius: 3px;
  505. }
  506. }
  507. }
  508. background-color: #fff;
  509. margin: 10px 0 0 10px;
  510. width: 100%;
  511. min-height: 700px;
  512. .news-no{
  513. margin: 120px auto;
  514. text-align: center;
  515. font-size: 20px;
  516. color: #999;
  517. img{
  518. width: 225px;
  519. height: 168px;
  520. }
  521. }
  522. .list{
  523. // height: 66px;
  524. background: #FFFFFF;
  525. border-bottom: 1px solid #D7DBE0;
  526. // padding: 0 60px 0 0;
  527. // margin: 20px 20px 0 20px;
  528. line-height: 66px;
  529. .evaluate-goods{
  530. display: flex;
  531. color: #333;
  532. font-size: 16px;
  533. margin: 20px 20px 0 20px;
  534. // justify-content: space-between;
  535. .color-s{
  536. color: #333330;
  537. font-size: 16px;
  538. }
  539. .order-button{
  540. width: 100px;
  541. height: 36px;
  542. background: #4171B3;
  543. border-radius: 2px;
  544. line-height: 140px;
  545. }
  546. .order-status{
  547. text-align: center;
  548. // width:400px!important;
  549. max-width: 400px;
  550. text-overflow: -o-ellipsis-lastline;
  551. overflow: hidden; //溢出内容隐藏
  552. text-overflow: ellipsis; //文本溢出部分用省略号表示
  553. display: -webkit-box; //特别显示模式
  554. -webkit-line-clamp: 2; //行数
  555. line-clamp: 2;
  556. -webkit-box-orient: vertical;
  557. font-size: 14px;
  558. line-height: normal;
  559. margin-top: 23px;
  560. //margin-right: 100px;
  561. }
  562. .order-money{
  563. //width: 200px;
  564. flex: 0 0 200px;
  565. // width: 300px;
  566. text-align: center;
  567. .order-button{
  568. width: 100px;
  569. height: 36px;
  570. background: #4171B3;
  571. border-radius: 2px;
  572. text-align: center;
  573. line-height: 36px;
  574. color: #fff;
  575. font-size: 16px;
  576. margin: 50px auto;
  577. }
  578. }
  579. .order-info{
  580. flex: 0 0 170px;
  581. text-align: center;
  582. .order-img{
  583. img{
  584. width: 100px;
  585. height: 100px;
  586. }
  587. }
  588. .order-name{
  589. font-size: 18px;
  590. color: #333;
  591. margin-left: 10px;
  592. line-height: 24px;
  593. }
  594. }
  595. }
  596. .list-tops{
  597. height: 34px;
  598. background: #F0F2F5;
  599. display: flex;
  600. line-height: 34px;
  601. padding: 0 70px 0 20px;
  602. .list-time{
  603. color: #999;
  604. font-size: 14px;
  605. }
  606. .orderNo{
  607. color: #999;
  608. font-size: 14px;
  609. margin-left: 20px;
  610. }
  611. .money-text{
  612. color: #333333;
  613. margin-left: 160px;
  614. font-size: 16px;
  615. }
  616. .money-status{
  617. color: #333333;
  618. margin-left: 190px;
  619. font-size: 16px;
  620. }
  621. .money-oper{
  622. color: #333333;
  623. margin-left: 180px;
  624. font-size: 16px;
  625. }
  626. }
  627. .list-right{
  628. text-align: right;
  629. .list-btn{
  630. color: #4171B3;
  631. cursor: pointer;
  632. font-size: 16px;
  633. }
  634. .time{
  635. color: #999;
  636. font-size: 16px;
  637. }
  638. }
  639. .list-cen{
  640. flex: 1;
  641. .content{
  642. color: #999;
  643. font-size: 16px;
  644. margin-left: 20px;
  645. }
  646. .name{
  647. color: #333;
  648. font-size: 20px;
  649. }
  650. }
  651. .list-img img{
  652. width: 90px;
  653. height: 70px;
  654. }
  655. }
  656. }
  657. .register-left{
  658. width: 320px;
  659. height: 100px;
  660. background: #FFFFFF;
  661. border-radius: 2px;
  662. margin-top: 10px;
  663. text-align: center;
  664. .colorStyle{
  665. color: #4B71AE!important;
  666. }
  667. .register-list{
  668. cursor: pointer;
  669. height: 100px;
  670. line-height: 100px;
  671. color: #333;
  672. font-size: 22px;
  673. }
  674. }
  675. }
  676. }
  677. </style>