remember.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <template>
  2. <view class="listAll">
  3. <!-- <navbar pageName="地址管理"></navbar> -->
  4. <view class="list" v-if="list.length == 0">
  5. <view class="nodata">
  6. <image src="../../static/identify/logo.png" mode=""></image>
  7. <view>还没有录入地址呦~</view>
  8. </view>
  9. <!-- <ul v-else>
  10. <li v-for="(item,index) in list" :key="index" :class="item.type == 1? 'active' : ''" @click="goExhibits(item,item.id,index)">
  11. <view class="checked"></view>
  12. <view class="add" >
  13. <view class="address">
  14. {{item.address}}{{item.name}}{{item.atlasAdd}}
  15. </view>
  16. <view class="namePhone">{{item.userName}} <span>{{item.phone}}</span></view>
  17. </view>
  18. <view class="edior">
  19. <view class="edit" @click.stop="edit(item.id)">编辑</view>
  20. <view class="del" @click.stop="del(item.id,item.type)">删除</view>
  21. </view>
  22. </li>
  23. </ul> -->
  24. </view>
  25. <view class="address_list" v-else>
  26. <view class="address" v-for="(item,index) in list" :key="index">
  27. <!-- <view class="checked"></view> -->
  28. <view class="add">
  29. <view class="data">
  30. {{item.address}} {{item.name}} {{item.atlasAdd}}
  31. </view>
  32. <view class="checked_box" @click="goExhibits(item,item.id,index)">
  33. <!-- <view class="checked" v-if="item.type == 0"></view> -->
  34. <view class="select" v-if="item.type == 0">
  35. <image src="../../static/identify/round.png" mode=""></image>
  36. </view>
  37. <view class="select" v-else>
  38. <image src="../../static/identify/select.png" mode=""></image>
  39. </view>
  40. 默认地址
  41. </view>
  42. <!-- <view class="namePhone">{{item.userName}} <span>{{item.phone}}</span></view> -->
  43. </view>
  44. <view class="edior">
  45. <view class="left">
  46. {{item.userName}} <span>{{item.phone}}</span>
  47. </view>
  48. <view class="right">
  49. <image src="../../static/identify/edit.png" mode="" style="margin-right: 20rpx;" @click.stop="edit(item.id)"></image>
  50. <image src="../../static/identify/delete.png" mode="" @click.stop="del(item.id,item.type)"></image>
  51. </view>
  52. </view>
  53. <!-- <view class="edior">
  54. <view class="edit" @click.stop="edit(item.id)">编辑</view>
  55. <view class="del" @click.stop="del(item.id,item.type)">删除</view>
  56. </view> -->
  57. </view>
  58. </view>
  59. <view class="addbtn">
  60. <button type="primary" @click="addAddress">新增地址</button>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. import {
  66. addList,
  67. delAdd,
  68. defaultAdd,
  69. updateOrder,
  70. addDetails
  71. } from '../.././api/index.js'
  72. export default {
  73. data() {
  74. return {
  75. list: [],
  76. checkedIndex: 0,
  77. title: '',
  78. orderId: '',
  79. address: {},
  80. cName: '',
  81. Cphone: ''
  82. }
  83. },
  84. methods: {
  85. getList() {
  86. var that = this
  87. var data = {
  88. openId: uni.getStorageSync('wx_copenid'),
  89. }
  90. addList(data).then(res => {
  91. // res.data.data.forEach((element, index) => {
  92. // element.address = JSON.parse(element.address)
  93. // if (element.type == 1) {
  94. // this.checkedIndex = index,
  95. // this.address = JSON.stringify(element.address),
  96. // this.cName = element.userName,
  97. // this.Cphone = element.phone
  98. // }
  99. // });
  100. this.list = res.data.data
  101. }).catch(err => {})
  102. },
  103. //设为默认地址
  104. goExhibits(item, id, index) {
  105. this.checkedIndex = index
  106. var id = {
  107. id: id,
  108. openid: uni.getStorageSync('wx_copenid'),
  109. }
  110. defaultAdd(id).then(res => {
  111. if (this.title == '支付订单') {
  112. addDetails(id).then(res => {
  113. if (res.data.code == 200) {
  114. var data = {
  115. cId: this.orderId,
  116. name: res.data.data.name,
  117. address: res.data.data.address,
  118. latitude: res.data.data.latitude,
  119. longitude: res.data.data.longitude,
  120. atlasAdd: res.data.data.atlasAdd,
  121. cName: res.data.data.userName,
  122. cPhone: res.data.data.phone
  123. }
  124. updateOrder(data).then(res => {
  125. if (res.data.code == 200) {
  126. uni.navigateBack()
  127. } else {
  128. uni.showToast({
  129. title: res.data.msg,
  130. icon: 'none'
  131. })
  132. }
  133. })
  134. setTimeout(() => {
  135. // uni.navigateBack()
  136. }, 2000)
  137. }
  138. })
  139. } else {
  140. if (res.data.code == 200) {
  141. this.getList()
  142. uni.showToast({
  143. title: '设置默认地址成功!',
  144. icon: 'none'
  145. })
  146. }
  147. }
  148. })
  149. },
  150. //编辑地址
  151. edit(id,type) {
  152. uni.navigateTo({
  153. url: './add_address?id=' + id+ '&type=' + type
  154. })
  155. },
  156. //删除地址
  157. del(id, type) {
  158. if (type == 1) {
  159. uni.showModal({
  160. title: '提示',
  161. content: '默认地址不能删除',
  162. confirmText: '确定', // 确定按钮的文字
  163. cancelText: '取消', // 取消按钮的文字
  164. })
  165. return
  166. }
  167. var id = id
  168. let that = this
  169. uni.showModal({
  170. title: '提示',
  171. content: '确定删除该地址吗?',
  172. confirmText: '确定', // 确定按钮的文字
  173. cancelText: '取消', // 取消按钮的文字
  174. success(res) {
  175. if (res.confirm) {
  176. delAdd({
  177. idList: id
  178. }).then(res => {
  179. if (res.data.code == 200) {
  180. // this.$router.go(0)
  181. that.getList()
  182. uni.showToast({
  183. title: '删除成功',
  184. icon: 'success',
  185. duration: 1000
  186. })
  187. }
  188. })
  189. } else if (res.cancel) {
  190. }
  191. }
  192. })
  193. },
  194. //新增地址
  195. addAddress() {
  196. var type = 0
  197. if (this.list.length < 1) {
  198. type = 1
  199. } else {
  200. type = 0
  201. }
  202. uni.navigateTo({
  203. // url: '../../my/addAddress/addAddress?type=' +type,
  204. url: './add_address?type=' + type,
  205. })
  206. },
  207. },
  208. onLoad(options) {
  209. this.title = options.name
  210. this.orderId = options.orderNo
  211. },
  212. onShow() {
  213. this.getList()
  214. }
  215. }
  216. </script>
  217. <style lang="scss" scoped>
  218. .listAll {
  219. height: 100vh;
  220. background-color: #f8f8f8;
  221. padding: 32rpx;
  222. box-sizing: border-box;
  223. }
  224. .list {
  225. padding: 32rpx;
  226. // li.active {
  227. // .checked {
  228. // background-color: #2cb8d4;
  229. // box-shadow: inset 0 0 5rpx 10rpx #fff;
  230. // }
  231. // }
  232. .nodata {
  233. text-align: center;
  234. padding-top: 200rpx;
  235. color: #666;
  236. image {
  237. width: 400rpx;
  238. height: 400rpx;
  239. margin-bottom: 20rpx;
  240. }
  241. }
  242. }
  243. .address_list {
  244. width: 100%;
  245. .address {
  246. width: 100%;
  247. // height: 82rpx;
  248. background: #FFFFFF;
  249. box-shadow: 0px 2rpx 6rpx 0px rgba(88, 209, 187, 0.05);
  250. border-radius: 10rpx 10rpx 10rpx 10rpx;
  251. padding: 32rpx 24rpx;
  252. margin-bottom: 30rpx;
  253. box-sizing: border-box;
  254. .add {
  255. flex: 1;
  256. // padding-right: 30px;
  257. display: flex;
  258. align-items: start;
  259. justify-content: space-between;
  260. margin-bottom: 16rpx;
  261. .data {
  262. // width: 75%;
  263. flex: 1;
  264. font-size: 32rpx;
  265. color: #333;
  266. font-weight: bold;
  267. margin-bottom: 10rpx;
  268. }
  269. .checked_box {
  270. width: 128rpx;
  271. display: flex;
  272. align-items: center;
  273. font-size: 24rpx;
  274. .select{
  275. display: flex;
  276. align-items: center;
  277. image{
  278. width: 24rpx;
  279. height: 24rpx;
  280. margin-right:8rpx ;
  281. }
  282. }
  283. }
  284. .namePhone {
  285. font-size: 28rpx;
  286. span {
  287. color: #a4a6a8;
  288. margin-left: 15rpx;
  289. }
  290. }
  291. }
  292. .edior {
  293. display: flex;
  294. align-items: center;
  295. justify-content: space-between;
  296. .left{
  297. font-size: 26rpx;
  298. span{
  299. font-size: 26rpx;
  300. color: #999999;
  301. margin-left: 20rpx;
  302. }
  303. }
  304. .right{
  305. image{
  306. width: 20px;
  307. height: 20px;
  308. }
  309. }
  310. }
  311. }
  312. }
  313. .addbtn {
  314. position: fixed;
  315. bottom: 0;
  316. width: 100%;
  317. background-color: #fff;
  318. border-top: 1px solid #ccc;
  319. padding-top: 15px;
  320. padding-bottom: 30px;
  321. button {
  322. margin: 0 50px;
  323. background-color: #2cb8d4;
  324. border-radius: 50px;
  325. }
  326. }
  327. </style>