金诚优选前端代码
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.

211 lines
5.0 KiB

  1. <template>
  2. <view id="address-list">
  3. <view class="list-box">
  4. <view class="list-item" :data-info="JSON.stringify(item)" :data-id="item.id" v-for="(item, index) in list" :key="index">
  5. <!-- <view class="user">
  6. <view class="name">
  7. <text>{{item.accept_name}}</text>
  8. <text class="phone">{{item.mobile}}</text>
  9. </view>
  10. <view class="default" v-if="item.is_default">
  11. 默认
  12. </view>
  13. </view>
  14. <view class="address">{{item.address_name}} {{item.address}}</view> -->
  15. <view class="lf-font-28 user-item" @tap="setInfo(item)">
  16. <text class="lf-color-black lf-font-bold">{{item.accept_name}}</text>
  17. <text class="lf-color-777 lf-m-l-20">{{item.mobile}}</text>
  18. </view>
  19. <view class="address-item lf-line-2" @tap="setInfo(item)">
  20. <text>{{item.address_name}}</text>
  21. <text>{{item.address}}</text>
  22. </view>
  23. <view class="menu-item lf-row-between lf-m-t-30">
  24. <view class="lf-row-center">
  25. <checkbox></checkbox>
  26. <text class="lf-m-l-15 lf-font-24 lf-color-777">默认地址</text>
  27. </view>
  28. <view class="lf-row-between">
  29. <view>
  30. <text class="lf-iconfont icon--1"></text>
  31. <text class="lf-m-l-10">编辑</text>
  32. </view>
  33. <view class="lf-m-l-50">
  34. <text class="lf-iconfont icon--1"></text>
  35. <text class="lf-m-l-10">删除</text>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="add-address" @tap="add">
  42. <view class="small-btn">
  43. <text class="lf-iconfont icon--2"></text>
  44. <text class="lf-m-l-10">新增收货地址</text>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import {pageLogin, getUrl,config,is} from '@/common/js/utils.js';
  51. export default {
  52. data() {
  53. return {
  54. list: [{
  55. accept_name: '加号',
  56. mobile: '12373873873',
  57. address_name: '广西南宁',
  58. address: '细丝里流向17号',
  59. is_default: true
  60. },{
  61. accept_name: '加号',
  62. mobile: '12373873873',
  63. address_name: '广西南宁',
  64. address: '细丝里流向17号',
  65. is_default: true
  66. }],
  67. order_no: '',
  68. url: '',
  69. id:''
  70. };
  71. },
  72. onShow() {
  73. this.queryAddressList(); // let app =getApp(); 暂时注释
  74. // app.isBirthday().then(()=>{
  75. // if(this.$cookieStorage.get("birthday_gift")){
  76. // var giftData=this.$cookieStorage.get("birthday_gift").data;
  77. // new app.ToastPannel().__page.showText(giftData);
  78. // }
  79. // });
  80. },
  81. onLoad(e) {
  82. // 暂时注释
  83. pageLogin(getUrl());
  84. this.setData({
  85. order_no: e.order_no,
  86. url: e.url
  87. });
  88. },
  89. components: {},
  90. props: {},
  91. methods: {
  92. setInfo(e) {
  93. // var from = e.currentTarget.dataset.info;
  94. var from = e;
  95. var data = this.$cookieStorage.get('order_form');
  96. // var from=JSON.parse(from);
  97. if (!data) {
  98. return this.view(from.id);
  99. }
  100. var order_no = this.order_no;
  101. if (order_no && data.order_no === order_no) {
  102. data.address = from;
  103. this.$cookieStorage.set('order_form', data);
  104. wx.navigateBack({
  105. url: '/' + this.url
  106. });
  107. } else {
  108. return this.view(from.id);
  109. }
  110. },
  111. view(id) {
  112. wx.navigateTo({
  113. url: '/pages/address/add/add?id=' + id
  114. });
  115. },
  116. add() {
  117. wx.navigateTo({
  118. url: '/pages/address/add/add'
  119. });
  120. },
  121. // 查询收货地址列表
  122. queryAddressList() {
  123. var token = this.$cookieStorage.get('user_token');
  124. this.$http.get({
  125. api: 'api/address',
  126. header: {
  127. Authorization: token
  128. }
  129. }).then(res => {
  130. if (res.statusCode == 200) {
  131. res = res.data;
  132. if (res.status) {
  133. this.setData({
  134. list: res.data
  135. });
  136. } else {
  137. wx.showToast({
  138. title: res.message,
  139. image: '../../../static/error.png'
  140. });
  141. }
  142. } else {
  143. wx.showToast({
  144. title: '获取信息失败',
  145. image: '../../../static/error.png'
  146. });
  147. }
  148. });
  149. },
  150. setData: function (obj) {
  151. let that = this;
  152. let keys = [];
  153. let val, data;
  154. Object.keys(obj).forEach(function (key) {
  155. keys = key.split('.');
  156. val = obj[key];
  157. data = that.$data;
  158. keys.forEach(function (key2, index) {
  159. if (index + 1 == keys.length) {
  160. that.$set(data, key2, val);
  161. } else {
  162. if (!data[key2]) {
  163. that.$set(data, key2, {});
  164. }
  165. }
  166. data = data[key2];
  167. });
  168. });
  169. }
  170. },
  171. computed: {},
  172. watch: {}
  173. };
  174. </script>
  175. <style>
  176. page{
  177. background-color: #F8F8F8;
  178. }
  179. </style>
  180. <style rel="stylesheet/less" lang="less">
  181. @import "list";
  182. .user-item, .menu-item{
  183. height: 50rpx;
  184. width: 100%;
  185. }
  186. .address-item{
  187. width: 100%;
  188. margin-top: 10rpx;
  189. font-size: 28rpx;
  190. color: #333333;
  191. }
  192. </style>