作者 朱振飞

1

正在显示 100 个修改的文件 包含 1393 行增加1 行删除

要显示太多修改。

为保证性能只显示 100 of 100+ 个文件。

packageA @ fa07629b
1 -Subproject commit fa07629bea63caece0380a34b13e14ad18f14b80  
  1 +const app=getApp()
  2 +Component({
  3 + /**
  4 + * 组件的属性列表
  5 + */
  6 + properties: {
  7 + list: Array
  8 + },
  9 +
  10 + /**
  11 + * 组件的初始数据
  12 + */
  13 + data: {
  14 +
  15 + },
  16 +
  17 + /**
  18 + * 组件的方法列表
  19 + */
  20 + methods: {
  21 + look_more(e) {
  22 + let login_new=app.globalData.login_new;
  23 + if(login_new==0){
  24 + wx.showToast({
  25 + title: '您还不是会员',
  26 + icon:"none"
  27 + })
  28 + setTimeout(function(){
  29 + wx.navigateTo({
  30 + url: '/packageA/pages/login/login',
  31 + })
  32 + },1500)
  33 + return false
  34 + }
  35 + let id = e.currentTarget.dataset.id
  36 + wx.navigateTo({
  37 + url: '/packageA/pages/shop_detail/shop_detail?id=' + id
  38 + })
  39 + },
  40 + },
  41 + lifetimes: {
  42 + created() {
  43 + // 在组件实例刚刚被创建时执行
  44 +
  45 +
  46 + },
  47 + attached() {
  48 + // 在组件实例进入页面节点树时执行
  49 + },
  50 + ready() {
  51 + // 在组件在视图层布局完成后执行
  52 + this.setData({
  53 + list: this.properties.list
  54 + })
  55 +
  56 + },
  57 + detached() {
  58 + // 在组件实例被从页面节点树移除时执行
  59 + },
  60 + }
  61 +})
  1 +{
  2 + "component": true,
  3 + "usingComponents": {}
  4 +}
  1 +<view class='real_goods'>
  2 + <view class="real_goods_item" wx:for="{{list}}" wx:key="index" data-id="{{item.id}}" bindtap="{{item.sold==0?'':'look_more'}}">
  3 + <view class='real_goods_img'>
  4 + <image src='{{item.images[0]}}' mode="aspectFill" />
  5 + <image src='/images/mei.png' class="tip" wx:if="{{item.sold == 0}}" />
  6 + </view>
  7 + <view class='real_goods_bottom'>
  8 + <view class='goods_title'>{{item.name}}</view>
  9 + <view wx:if="{{item.price2!=null}}">
  10 +
  11 + <view class='goods_flex'>
  12 + <view class='price'>¥{{item.price}}</view>
  13 + <view class="lineprice" wx:if="{{item.line_price!=null}}">¥{{item.line_price}}</view>
  14 + <view class='sell'>已卖出{{item.sales}}件</view>
  15 + </view>
  16 +
  17 + <!-- <view class='oldprice'>{{item.price}}</view> -->
  18 + </view>
  19 +
  20 + <view class='goods_flex' wx:else>
  21 + <!-- <view class='score'>积分</view> -->
  22 + <view class='price'>¥{{item.price}}</view>
  23 + <view class="lineprice" wx:if="{{item.line_price!=null}}">¥{{item.line_price}}</view>
  24 + <view class='sell'>已卖出{{item.sales}}件</view>
  25 + </view>
  26 + </view>
  27 + <view class="pink_cover" wx:if="{{item.sold==0}}" />
  28 + </view>
  29 +</view>
  1 +.real_goods {
  2 + width: 750rpx;
  3 + margin: 0 auto;
  4 + background: #f9f9f9;
  5 + display: flex;
  6 + flex-wrap: wrap;
  7 + padding: 8rpx 0 20rpx;
  8 + box-sizing: border-box;
  9 + margin-bottom:120rpx;
  10 +}
  11 +
  12 +.real_goods_item {
  13 + width: 367rpx;
  14 + margin-top: 20rpx;
  15 + border-radius: 10rpx;
  16 + background: #fff;
  17 + overflow: hidden;
  18 + position: relative;
  19 + display:flex;
  20 + flex-direction: column;
  21 +
  22 + align-items: center;
  23 +
  24 +}
  25 +.real_goods_item:nth-child(2n){
  26 + border-left:16rpx solid #f5f5f5;
  27 +}
  28 +
  29 +.real_goods_img {
  30 + width: 332rpx;
  31 + height: 332rpx;
  32 + margin-bottom: 16rpx;
  33 + border-top-left-radius: 10rpx;
  34 + border-top-right-radius: 10rpx;
  35 + overflow: hidden;
  36 + position: relative;
  37 +}
  38 +
  39 +.real_goods_img image {
  40 + width: 100%;
  41 + height: 100%;
  42 +}
  43 +
  44 +.tip {
  45 + width: 87rpx !important;
  46 + height: 80rpx !important;
  47 + position: absolute;
  48 + right: 0;
  49 + top: 0;
  50 + z-index: 2;
  51 +}
  52 +
  53 +.real_goods_bottom {
  54 + padding: 16rpx 32rpx 28rpx 32rpx;
  55 + box-sizing: border-box;
  56 + background: #fff;
  57 +}
  58 +
  59 +.goods_title {
  60 +
  61 + font-size: 26rpx;
  62 + font-family: PingFang SC;
  63 + font-weight: 500;
  64 + line-height: 36rpx;
  65 + color: rgba(5, 9, 26, 1);
  66 + overflow: hidden;
  67 + text-overflow: ellipsis;
  68 + display: -webkit-box;
  69 + -webkit-box-orient: vertical;
  70 + -webkit-line-clamp: 2;
  71 + margin-bottom: 10rpx;
  72 +}
  73 +
  74 +.goods_flex {
  75 + height: 50rpx;
  76 + display: flex;
  77 + align-items: center;
  78 +}
  79 +
  80 +.score {
  81 + width: 64rpx;
  82 + height: 32rpx;
  83 + background: rgba(242, 0, 0, 1);
  84 + border-radius: 2rpx;
  85 + text-align: center;
  86 + color: #fff;
  87 + font-size: 22rpx;
  88 + font-family: PingFang SC;
  89 + font-weight: 400;
  90 + margin-right: 12rpx;
  91 +}
  92 +
  93 +.price {
  94 + font-size:36rpx;
  95 + font-family: PingFang SC;
  96 + font-weight: bold;
  97 + color: rgba(242, 0, 0, 1);
  98 + margin-right: 20rpx;
  99 +}
  100 +
  101 +.sell {
  102 + font-size: 20rpx;
  103 + font-family: PingFang SC;
  104 + font-weight: 400;
  105 + color: rgba(156, 156, 156, 1);
  106 +}
  107 +
  108 +.pink_cover{
  109 + width: 100%;
  110 + height: 100%;
  111 + background: #ccc;
  112 + opacity: 0.3;
  113 + position: absolute;
  114 + left: 0;
  115 + top: 0;
  116 +}
  117 +.oldprice{
  118 + color:#BDC4CE;
  119 + font-size: 24rpx;
  120 + text-decoration: line-through
  121 +}
  122 +.lineprice{
  123 + color: rgba(156, 156, 156, 1);
  124 + text-decoration: line-through;
  125 + font-size: 20rpx;
  126 + margin-right:5rpx;
  127 +
  128 +}
  1 +
  2 +Component({
  3 + /**
  4 + * 组件的属性列表
  5 + */
  6 + properties: {
  7 +
  8 + },
  9 +
  10 + /**
  11 + * 组件的初始数据
  12 + */
  13 + data: {
  14 +
  15 + },
  16 +
  17 + /**
  18 + * 组件的方法列表
  19 + */
  20 + methods: {
  21 + tel(){
  22 + wx.makePhoneCall({
  23 + phoneNumber: wx.getStorageSync('tel')
  24 + })
  25 + }
  26 + }
  27 +})
  1 +{
  2 + "component": true,
  3 + "usingComponents": {}
  4 +}
  1 +<view class="concat_box">
  2 + <button open-type="contact" class="item" plain="true">
  3 + <image src="/images/icon_65.png" />
  4 + </button>
  5 + <view class="item" catchtap="tel">
  6 + <image src="/images/bodadianhua_icon.png" />
  7 + </view>
  8 +</view>
  1 +.concat_box {
  2 + width: 96rpx;
  3 + height: 210rpx;
  4 + position: fixed;
  5 + right: -24rpx;
  6 + bottom: 100rpx;
  7 +}
  8 +
  9 +.item {
  10 + width: 60rpx;
  11 + height: 60rpx;
  12 + padding: 0;
  13 + border: none !important;
  14 + margin: 0 !important;
  15 +}
  16 +
  17 +.item:first-child {
  18 + margin-bottom: 30rpx !important;
  19 +}
  20 +
  21 +.item image {
  22 + width: 100%;
  23 + height: 100%;
  24 +}
  1 +Component({
  2 + /**
  3 + * 组件的属性列表
  4 + */
  5 + properties: {
  6 + check_num: Number, //已选择商品数量
  7 + list: Array,
  8 + type: Number,
  9 + checkAll: Boolean
  10 + },
  11 +
  12 + /**
  13 + * 组件的初始数据
  14 + */
  15 + data: {
  16 +
  17 + },
  18 +
  19 + /**
  20 + * 组件的方法列表
  21 + */
  22 + methods: {
  23 + //查看商品详情
  24 + look_detail(e) {
  25 + let id = e.currentTarget.dataset.id;
  26 +
  27 + // wx.navigateTo({
  28 + // url: '/pages/shop_detail/shop_detail?id=' + id
  29 + // })
  30 + },
  31 + enter(){
  32 + console.log(this.data.list)
  33 + },
  34 + //加减商品数量
  35 + num_change(e) {
  36 + let num = Number(e.currentTarget.dataset.num)
  37 + let type = e.currentTarget.dataset.type
  38 + let index = e.currentTarget.dataset.index
  39 + let id = e.currentTarget.dataset.id
  40 + let product_id = e.currentTarget.dataset.product_id
  41 + if (type == 1) {
  42 + num++
  43 + } else {
  44 + num--
  45 + if (num < 1) {
  46 + //触发删除商品的接口
  47 +
  48 + this.triggerEvent('delete_shop', {
  49 + index: index,
  50 + id: id
  51 + })
  52 + return
  53 + }
  54 + }
  55 + this.triggerEvent('change_num', {
  56 + num: num,
  57 + index: index,
  58 + type: type,
  59 + product_id: product_id
  60 + })
  61 + },
  62 + //改变商品选中状态
  63 + check_item(e){
  64 + let index = e.currentTarget.dataset.index
  65 + let check_type = e.currentTarget.dataset.check_type ? e.currentTarget.dataset.check_type:false
  66 + let check_num = Number(this.data.check_num)
  67 + if (!check_type){
  68 + check_num ++
  69 + } else {
  70 + check_num --
  71 + }
  72 + this.triggerEvent('check_type', {
  73 + index: index,
  74 + check_type: !check_type,
  75 + check_num: check_num
  76 + })
  77 + }
  78 + },
  79 + lifetimes: {
  80 + created() {
  81 + // 在组件实例刚刚被创建时执行
  82 +
  83 +
  84 + },
  85 + attached() {
  86 + // 在组件实例进入页面节点树时执行
  87 + },
  88 + ready() {
  89 + // 在组件在视图层布局完成后执行
  90 + this.setData({
  91 + list: this.properties.list,
  92 + type: this.properties.type,
  93 + checkAll: this.properties.checkAll,
  94 + check_num: this.properties.check_num ? this.properties.check_num:0
  95 + })
  96 +
  97 + console.log(this.data.list)
  98 +
  99 + },
  100 + detached() {
  101 + // 在组件实例被从页面节点树移除时执行
  102 + },
  103 + }
  104 +})
  1 +{
  2 + "component": true,
  3 + "usingComponents": {}
  4 +}
  1 +<view class="item" wx:for="{{list}}" wx:key="index">
  2 + <view class="top">
  3 + <image class="check_box" src="{{item.check_type?'/images/check@.png':'/images/check.png'}}" wx:if="{{type == 1 || type == 2}}" catchtap="check_item" data-check_type="{{item.check_type}}" data-index="{{index}}" />
  4 + <view class="content {{type==3?'active':''}}">
  5 + <image class="show_img" src="{{type == 3?item.images[0]:type==4?item.product.images[0]:type==2?item.image:item.product.allimages[0]}}" mode="aspectFill" bindtap="{{type == 1 || type == 2?'look_detail':''}}" data-id="{{item.product_id}}"/>
  6 + <view class="right {{type==3?'ractive':''}}">
  7 + <view class="word">{{type == 3?item.name:type==2?item.product_name:item.product.name}}</view>
  8 + <view class="info">
  9 + <view class="jifen">
  10 + <view class="name">积分</view>
  11 + <text wx:if='{{item.product.price2!=null||item.price2!=null}}'>{{type == 3 || type == 2?item.price2:item.product.price2}}</text>
  12 + <text wx:else>{{type == 3 || type == 2?item.price:item.product.price}}</text>
  13 + <text style="margin-left: 10rpx;color:#ccc;font-size: 28rpx;" wx:if="{{type == 3 || type == 4}}">X{{item.num}}</text>
  14 + </view>
  15 + <view class="num_box" wx:if="{{type == 1}}">
  16 + <image class="num_btn" src="/images/reduce.png" data-index="{{index}}" data-type="0" data-num="{{item.num}}" data-id="{{item.id}}" data-product_id="{{item.product_id}}" catchtap="num_change" />
  17 + <text>{{item.num}}</text>
  18 + <image class="num_btn" src="/images/add.png" data-index="{{index}}" data-type="1" data-num="{{item.num}}" data-id="{{item.id}}" data-product_id="{{item.product_id}}" catchtap="num_change"/>
  19 + </view>
  20 + </view>
  21 + <!-- <view class="oldprice" wx:if="{{item.product.price2!=null||item.price2!=null}}">{{item.product.price||item.price}}</view> -->
  22 + </view>
  23 + </view>
  24 + </view>
  25 + <view class="info_box" wx:if="{{type == 3}}">
  26 + <view class="f_item">
  27 + <view class="shop" bindtap="enter">
  28 + 商品积分
  29 + <text wx:if="{{item.price2!=null}}">{{item.price2*100*item.num/100}}积分</text>
  30 + <text wx:else>{{item.price*100*item.num/100}}积分</text>
  31 + </view>
  32 + </view>
  33 + </view>
  34 +</view>
  1 +.item {
  2 + width: 100%;
  3 + background: #fff;
  4 + padding: 0 24rpx;
  5 + box-sizing: border-box;
  6 + margin-top: 20rpx;
  7 +}
  8 +
  9 +.item:first-child {
  10 + margin-top: 0;
  11 +}
  12 +
  13 +.item .top {
  14 + padding: 36rpx 0;
  15 + box-sizing: border-box;
  16 + display: flex;
  17 + align-items: center;
  18 +}
  19 +
  20 +.check_box {
  21 + width: 36rpx;
  22 + height: 36rpx;
  23 + padding: 30rpx 30rpx 30rpx 0;
  24 +}
  25 +
  26 +.content {
  27 + width: 564rpx;
  28 + display: flex;
  29 + justify-content: space-between;
  30 + align-items: center;
  31 +}
  32 +
  33 +.show_img {
  34 + width: 164rpx;
  35 + height: 164rpx;
  36 + margin-right: 24rpx;
  37 +}
  38 +
  39 +.right {
  40 + width: 376rpx;
  41 +}
  42 +
  43 +.word {
  44 + width: 100%;
  45 + height: 76rpx;
  46 + font-size: 28rpx;
  47 + font-family: PingFang SC;
  48 + font-weight: 400;
  49 + overflow: hidden;
  50 + text-overflow: ellipsis;
  51 + display: -webkit-box;
  52 + word-break: break-all;
  53 + -webkit-box-orient: vertical;
  54 + -webkit-line-clamp: 2;
  55 +}
  56 +
  57 +.info {
  58 + display: flex;
  59 + align-items: center;
  60 + justify-content: space-between;
  61 + margin-top: 32rpx;
  62 +}
  63 +
  64 +.jifen {
  65 + display: flex;
  66 + align-items: center;
  67 +}
  68 +
  69 +.jifen .name {
  70 + width: 64rpx;
  71 + height: 36rpx;
  72 + background: rgba(242, 0, 0, 1);
  73 + border-radius: 4rpx;
  74 + font-size: 22rpx;
  75 + font-family: PingFang SC;
  76 + font-weight: 400;
  77 + color: #fff;
  78 + display: flex;
  79 + justify-content: center;
  80 + align-items: center;
  81 + margin-right: 20rpx;
  82 +}
  83 +
  84 +.jifen text {
  85 + font-size: 26rpx;
  86 + font-family: PingFang SC;
  87 + font-weight: bold;
  88 + color: rgba(242, 0, 0, 1);
  89 +}
  90 +
  91 +.num_box {
  92 + display: flex;
  93 + align-items: center;
  94 + justify-content: space-between;
  95 +}
  96 +
  97 +.num_box .num_btn {
  98 + width: 36rpx;
  99 + height: 36rpx;
  100 +}
  101 +
  102 +.num_box text {
  103 + font-size: 30rpx;
  104 + font-family: PingFang SC;
  105 + font-weight: 400;
  106 + color: rgba(19, 26, 46, 1);
  107 + margin: 0 24rpx;
  108 +}
  109 +
  110 +.active {
  111 + width: 100%;
  112 +}
  113 +
  114 +.ractive {
  115 + width: 448rpx;
  116 +}
  117 +
  118 +.info_box {
  119 + width: 100%;
  120 + margin-top: 26rpx;
  121 +}
  122 +
  123 +.f_item {
  124 + width: 100%;
  125 + padding: 28rpx 0;
  126 + box-sizing: border-box;
  127 + border-bottom: 1px solid #eee;
  128 +}
  129 +
  130 +.f_item .shop {
  131 + width: 100%;
  132 + font-size: 28rpx;
  133 + font-family: PingFang SC;
  134 + font-weight: 400;
  135 + color: rgba(19, 26, 46, 1);
  136 + display: flex;
  137 + justify-content: space-between;
  138 + align-items: center;
  139 +}
  140 +
  141 +.f_item .shop text:last-child {
  142 + color: #8e8e8e;
  143 +}
  144 +
  145 +.youfei {
  146 + font-size: 24rpx;
  147 + font-family: PingFang SC;
  148 + font-weight: 400;
  149 + line-height: 34rpx;
  150 + color: rgba(142, 142, 142, 1);
  151 + margin-top: 10rxp;
  152 +}
  153 +
  154 +.jifen_num {
  155 + width: 100%;
  156 + padding: 28rpx 0;
  157 + box-sizing: border-box;
  158 + display: flex;
  159 + flex-direction: row-reverse;
  160 + align-items: center;
  161 + font-size: 28rpx;
  162 + font-family: PingFang SC;
  163 + font-weight: Regular;
  164 + color: #131a2e;
  165 +}
  166 +
  167 +.jifen_num text:last-child {
  168 + font-size: 32rpx;
  169 + color: rgba(242, 0, 0, 1);
  170 + font-family: PingFang SC Bold;
  171 + font-weight: Bold;
  172 +}
  173 +
  174 +.jifen_num text:first-child {
  175 + color: rgba(242, 0, 0, 1);
  176 + margin-left: 10rpx;
  177 +}
  178 +
  179 +.oldprice {
  180 + color: #bdc4ce;
  181 + font-size: 24rpx;
  182 + text-decoration: line-through;
  183 + margin-top:10rpx;
  184 +}
  1 +const app = getApp()
  2 +Page({
  3 +
  4 + /**
  5 + * 页面的初始数据
  6 + */
  7 + data: {
  8 + check_num: 0, //选中数量
  9 + checkAll: false, //全选状态
  10 + check_str: ''
  11 + },
  12 + //改变商品状态
  13 + check_type(e) {
  14 + let index = Number(e.detail.index)
  15 + this.setData({
  16 + [`list[${index}].check_type`]: e.detail.check_type,
  17 + check_num: e.detail.check_num
  18 + })
  19 + if (e.detail.check_num == this.data.list.length) {
  20 + this.setData({
  21 + checkAll: true
  22 + })
  23 + } else if (e.detail.check_num == 0) {
  24 + this.setData({
  25 + checkAll: false
  26 + })
  27 + }
  28 + this.get_all()
  29 + },
  30 + //全选|全不选
  31 + check_all() {
  32 + let list = this.data.list
  33 + for (let obj of list) {
  34 + obj.check_type = !this.data.checkAll
  35 + }
  36 + this.setData({
  37 + checkAll: !this.data.checkAll,
  38 + list: list,
  39 + check_num: !this.data.checkAll ? list.length : 0
  40 + })
  41 + this.get_all()
  42 + },
  43 + //获取选中商品
  44 + get_all() {
  45 + let that = this
  46 + let list = that.data.list
  47 + let check_str = ''
  48 + for (let obj of list) {
  49 + if (obj.check_type) {
  50 + if (check_str == ""){
  51 + check_str = obj.id
  52 + } else {
  53 + check_str = check_str + ',' + obj.id
  54 + }
  55 + }
  56 + }
  57 + that.setData({
  58 + check_str: check_str
  59 + })
  60 + },
  61 + delete_item(){
  62 + if (this.data.check_str == ""){
  63 + wx.showToast({
  64 + title: '请先选中商品',
  65 + icon: 'none',
  66 + duration: 1000
  67 + })
  68 + return
  69 + }
  70 + let url = app.interface.collectdel
  71 + let params = {
  72 + ids: this.data.check_str
  73 + }
  74 + app.post(url,params).then((res)=>{
  75 + wx.showToast({
  76 + title: '删除成功',
  77 + duration: 1000
  78 + })
  79 + this.get_info()
  80 + })
  81 + },
  82 +//获取页面信息
  83 + get_info() {
  84 + wx.showLoading({
  85 + title: '加载中'
  86 + })
  87 + let that = this
  88 + let url = app.interface.collectList
  89 + app.post(url, {}).then((res) => {
  90 + wx.hideLoading()
  91 + that.setData({
  92 + list: res.msg
  93 + })
  94 + })
  95 + },
  96 +
  97 +
  98 + /**
  99 + * 生命周期函数--监听页面加载
  100 + */
  101 + onLoad: function(options) {
  102 + this.get_info()
  103 + },
  104 +
  105 + /**
  106 + * 生命周期函数--监听页面初次渲染完成
  107 + */
  108 + onReady: function() {
  109 +
  110 + },
  111 +
  112 + /**
  113 + * 生命周期函数--监听页面显示
  114 + */
  115 + onShow: function() {
  116 +
  117 + },
  118 +
  119 + /**
  120 + * 生命周期函数--监听页面隐藏
  121 + */
  122 + onHide: function() {
  123 +
  124 + },
  125 +
  126 + /**
  127 + * 生命周期函数--监听页面卸载
  128 + */
  129 + onUnload: function() {
  130 +
  131 + },
  132 +
  133 + /**
  134 + * 页面相关事件处理函数--监听用户下拉动作
  135 + */
  136 + onPullDownRefresh: function() {
  137 +
  138 + },
  139 +
  140 + /**
  141 + * 页面上拉触底事件的处理函数
  142 + */
  143 + onReachBottom: function() {
  144 +
  145 + },
  146 +
  147 + /**
  148 + * 用户点击右上角分享
  149 + */
  150 + onShareAppMessage: function() {
  151 +
  152 + }
  153 +})
  1 +{
  2 + "navigationBarTitleText": "我的收藏",
  3 + "usingComponents": {
  4 + "shop_item": "/Components/shop_item/shop_item"
  5 + }
  6 +}
  1 +<view class="content">
  2 + <shop_item list="{{list}}" type="2" bindcheck_type="check_type" check_num="{{check_num}}" />
  3 + <view class="empty" wx:if="{{list.length == 0}}">暂无更多数据</view>
  4 +</view>
  5 +
  6 +<view class="footer" wx:if="{{list.length>0}}">
  7 + <view class="check_box" bindtap="check_all">
  8 + <image class="check" src="{{checkAll?'/images/check@.png':'/images/check.png'}}" />
  9 + <text>全选</text>
  10 + </view>
  11 + <view class="del" catchtap="delete_item">删除</view>
  12 +</view>
  1 +page {
  2 + background: #f9f9f9;
  3 +}
  4 +
  5 +.content {
  6 + width: 100%;
  7 + padding: 30rpx 32rpx 120rpx;
  8 + box-sizing: border-box;
  9 +}
  10 +
  11 +.footer {
  12 + width: 100%;
  13 + height: 100rpx;
  14 + padding: 0 32rpx;
  15 + box-sizing: border-box;
  16 + background: #fff;
  17 + position: fixed;
  18 + left: 0;
  19 + bottom: 0;
  20 + display: flex;
  21 + justify-content: space-between;
  22 + align-items: center;
  23 +}
  24 +
  25 +.footer .check_box {
  26 + display: flex;
  27 + align-items: center;
  28 + font-size: 26rpx;
  29 + font-family: PingFang SC;
  30 + font-weight: 400;
  31 + color: rgba(19, 26, 46, 1);
  32 +}
  33 +
  34 +.footer .check_box .check {
  35 + width: 36rpx;
  36 + height: 36rpx;
  37 + padding: 20rpx 20rpx 20rpx 0;
  38 +}
  39 +
  40 +.footer .del {
  41 + width: 180rpx;
  42 + height: 68rpx;
  43 + background: rgba(242, 0, 0, 1);
  44 + border-radius: 34rpx;
  45 + font-size: 30rpx;
  46 + font-family: PingFang SC;
  47 + font-weight: 400;
  48 + color: rgba(255, 255, 255, 1);
  49 + display: flex;
  50 + justify-content: center;
  51 + align-items: center;
  52 +}
  53 +.empty {
  54 + font-size: 36rpx;
  55 + font-family: PingFang SC;
  56 + font-weight: 400;
  57 + color: #ccc;
  58 + margin-top: 200rpx;
  59 + text-align: center;
  60 +}
  1 +const a = getApp();
  2 +Page({
  3 +
  4 + /**
  5 + * 页面的初始数据
  6 + */
  7 + data: {
  8 + name: '',
  9 + tel: '',
  10 + area: '',
  11 + address: '',
  12 + mr: 0
  13 + },
  14 +
  15 + /**
  16 + * 生命周期函数--监听页面加载
  17 + */
  18 + onLoad: function(options) {
  19 +
  20 + },
  21 +
  22 + // 获取名字
  23 + nameFun(e) {
  24 + this.setData({
  25 + name: e.detail.value.replace(/\s+/g, '')
  26 + })
  27 + },
  28 +
  29 + // 获取手机号
  30 + telFun(e) {
  31 + this.setData({
  32 + tel: e.detail.value.replace(/\s+/g, '')
  33 + })
  34 + },
  35 +
  36 + // 获取详细地址
  37 + getAddressFun(e) {
  38 + this.setData({
  39 + address: e.detail.value
  40 + })
  41 + },
  42 +
  43 + bindRegionChange(e) {
  44 + this.setData({
  45 + area: e.detail.value[0] + ' ' + e.detail.value[1] + ' ' + e.detail.value[2]
  46 + })
  47 + },
  48 +
  49 + // 设置默认地址
  50 + switchChange(e) {
  51 + if (e.detail.value) {
  52 + this.setData({
  53 + mr: 1
  54 + })
  55 + } else {
  56 + this.setData({
  57 + mr: 0
  58 + })
  59 + }
  60 + },
  61 +
  62 + // 保存地址
  63 + addFun() {
  64 + let t = this;
  65 + let AuglyTest_phone = /^1(3|4|5|6|7|8|9)\d{9}$/;
  66 + let u = a.interface.addaddress;
  67 + let d = {
  68 + tel: t.data.tel,
  69 + name: t.data.name,
  70 + area: t.data.area,
  71 + address: t.data.address,
  72 + mo: t.data.mr
  73 + }
  74 + if (d.name == '') {
  75 + wx.showToast({
  76 + title: '请输入收货人名称',
  77 + icon: 'none',
  78 + duration: 1300
  79 + })
  80 + } else if (d.tel == '') {
  81 + wx.showToast({
  82 + title: '请输入手机号',
  83 + icon: 'none',
  84 + duration: 1300
  85 + })
  86 + } else if (!AuglyTest_phone.test(d.tel)) {
  87 + wx.showToast({
  88 + title: '请输入正确的手机号',
  89 + icon: 'none',
  90 + duration: 1300
  91 + })
  92 + } else if (d.area == '') {
  93 + wx.showToast({
  94 + title: '请选择省市区',
  95 + icon: 'none',
  96 + duration: 1300
  97 + })
  98 + } else if (d.address == '') {
  99 + wx.showToast({
  100 + title: '请输入详细地址',
  101 + icon: 'none',
  102 + duration: 1300
  103 + })
  104 +
  105 + } else {
  106 + a.post(u, d).then((r) => {
  107 + if (r.code == 200) {
  108 + wx.showToast({
  109 + title: '保存成功',
  110 + icon: 'none',
  111 + duration: 1300
  112 + })
  113 + setTimeout(() => {
  114 + wx.navigateBack()
  115 + }, 1300)
  116 + }
  117 + })
  118 + }
  119 + },
  120 +
  121 + /**
  122 + * 生命周期函数--监听页面初次渲染完成
  123 + */
  124 + onReady: function() {
  125 +
  126 + },
  127 +
  128 + /**
  129 + * 生命周期函数--监听页面显示
  130 + */
  131 + onShow: function() {
  132 +
  133 + },
  134 +
  135 + /**
  136 + * 生命周期函数--监听页面隐藏
  137 + */
  138 + onHide: function() {
  139 +
  140 + },
  141 +
  142 + /**
  143 + * 生命周期函数--监听页面卸载
  144 + */
  145 + onUnload: function() {
  146 +
  147 + },
  148 +
  149 + /**
  150 + * 页面相关事件处理函数--监听用户下拉动作
  151 + */
  152 + onPullDownRefresh: function() {
  153 +
  154 + },
  155 +
  156 + /**
  157 + * 页面上拉触底事件的处理函数
  158 + */
  159 + onReachBottom: function() {
  160 +
  161 + },
  162 +
  163 + /**
  164 + * 用户点击右上角分享
  165 + */
  166 + onShareAppMessage: function() {
  167 +
  168 + }
  169 +})
  1 +{
  2 + "navigationBarTitleText": "新增地址"
  3 +}
  1 +<view class="box">
  2 + <view class="list">
  3 + <view class="list_left">收货人</view>
  4 + <view class="list_right">
  5 + <input placeholder="请输入收货人" bindinput="nameFun" placeholder-class="inut_plclass"></input>
  6 + </view>
  7 + </view>
  8 + <view class="list">
  9 + <view class="list_left">手机号码</view>
  10 + <view class="list_right">
  11 + <input placeholder="请输入手机号" type="number" maxlength="11" bindinput="telFun" placeholder-class="inut_plclass"></input>
  12 + </view>
  13 + </view>
  14 + <picker mode="region" style="width: 100%;" bindchange="bindRegionChange">
  15 + <view class="list">
  16 + <view class="list_left">所在地区</view>
  17 + <view class="list_right">
  18 + <view class="area">{{area}}</view>
  19 + <view class="list_right_img">
  20 + <image src="/images/youjiantou.png"></image>
  21 + </view>
  22 + </view>
  23 + </view>
  24 + </picker>
  25 + <view class="list_textarea">
  26 + <view class="list_left">详细地址</view>
  27 + <view class="list_right">
  28 + <!-- style="padding-top:22rpx;" -->
  29 + <textarea placeholder="道路、门牌号、小区、楼栋号等" placeholder-class="inut_plclass" bindinput="getAddressFun" style="padding-top:2rpx;" ></textarea>
  30 + </view>
  31 + </view>
  32 + <view class="list">
  33 + <view class="list_left">设为默认地址</view>
  34 + <view class="list_right">
  35 + <switch type="switch" color="rgba(242, 0, 0, 1)" bindchange="switchChange" />
  36 + </view>
  37 + </view>
  38 +</view>
  39 +
  40 +
  41 +
  42 +
  43 +
  44 +<view class="add_btn_box">
  45 + <view class="add_btn" bindtap="addFun">保存</view>
  46 +</view>
  1 +
  2 +page {
  3 + width: 100%;
  4 + height: 100%;
  5 +}
  6 +
  7 +.box {
  8 + width: 100%;
  9 + height: 200%;
  10 + background: rgba(255, 255, 255, 1);
  11 + box-sizing: border-box;
  12 + padding-left: 32rpx;
  13 +}
  14 +
  15 +.list,.list_textarea {
  16 + width: 100%;
  17 + height: 122rpx;
  18 + box-sizing: border-box;
  19 + display: flex;
  20 + justify-content: space-between;
  21 + align-items: center;
  22 + padding-right: 32rpx;
  23 + border-bottom: 1px solid rgba(238, 238, 238, 1);
  24 +}
  25 +
  26 +.list_textarea {
  27 + height: 202rpx;
  28 + align-items: flex-start;
  29 + padding: 40rpx 32rpx 40rpx 0;
  30 +}
  31 +
  32 +.list_left {
  33 + min-width: 166rpx;
  34 +}
  35 +
  36 +
  37 +.list_right {
  38 + flex: 1;
  39 + height: 100%;
  40 + display: flex;
  41 + justify-content: flex-end;
  42 + align-items: center;
  43 + margin-top: 10ropx;
  44 +}
  45 +
  46 +.area {
  47 + flex: 1;
  48 + font-size: 30rpx;
  49 + color: rgba(19, 26, 46, 1);
  50 + font-weight: bold;
  51 +}
  52 +
  53 +.list_right_img {
  54 + width: 48rpx;
  55 + height: 48rpx;
  56 +}
  57 +
  58 +.list_right_img image {
  59 + display: block;
  60 + width: 100%;
  61 + height: 100%;
  62 +}
  63 +
  64 +.list_right input,.list_textarea textarea {
  65 + flex: 1;
  66 + height: 100%;
  67 + color: rgba(19, 26, 46, 1);
  68 + font-size: 30rpx;
  69 + font-weight: bold;
  70 + display: block;
  71 +}
  72 +
  73 +.list_textarea textarea {
  74 + width: 100%;
  75 +}
  76 +
  77 +.inut_plclass {
  78 + font-weight: normal;
  79 +}
  80 +
  81 +.add_btn_box {
  82 + width: 100%;
  83 + box-sizing: border-box;
  84 + padding: 32rpx;
  85 + background: rgba(255, 255, 255, 1);
  86 + position: fixed;
  87 + bottom: 0;
  88 + left: 0;
  89 +}
  90 +
  91 +.add_btn {
  92 + width: 100%;
  93 + height: 80rpx;
  94 + background: rgba(242, 0, 0, 1);
  95 + border-radius: 40rpx;
  96 + display: flex;
  97 + justify-content: center;
  98 + align-items: center;
  99 + font-size: 30rpx;
  100 + color: rgba(255, 255, 255, 1);
  101 +}
  102 +
  103 +
  104 +
  105 +
  106 +
  107 +
  108 +
  109 +
  110 +
  111 +
  112 +
  113 +
  114 +
  115 +
  116 +
  117 +
  118 +
  119 +
  120 +
  121 +
  122 +
  123 +
  124 +
  125 +
  126 +
  127 +
  128 +
  129 +
  130 +
  131 +
  132 +
  133 +
  134 +
  135 +
  1 +const a = getApp();
  2 +Page({
  3 +
  4 + /**
  5 + * 页面的初始数据
  6 + */
  7 + data: {
  8 + list: [],
  9 + },
  10 + /**
  11 + * 生命周期函数--监听页面加载
  12 + */
  13 + onLoad: function(options) {
  14 +
  15 + },
  16 + // 获取地址列表
  17 + getListFun() {
  18 + let t = this;
  19 + let u = a.interface.address
  20 + a.post(u, {}).then((r) => {
  21 + if (r.code == 200) {
  22 + t.setData({
  23 + list: r.msg,
  24 + check: true
  25 + })
  26 + if (r.msg.length == 0){
  27 + wx.setStorageSync('no_address', true)
  28 + }
  29 + }
  30 + }).catch((er) => {
  31 + })
  32 + },
  33 +
  34 + //选择地址返回确认订单页面
  35 + selectAdddressFun(e) {
  36 + console.log(e)
  37 + let pages = getCurrentPages();
  38 + let prevPage = pages[pages.length - 2]; //上一个页面
  39 + //直接调用上一个页面的setData()方法,把数据存到上一个页面中去
  40 + prevPage.setData({
  41 + name: e.currentTarget.dataset.n,
  42 + area: e.currentTarget.dataset.a,
  43 + tel: e.currentTarget.dataset.tel,
  44 + address: e.currentTarget.dataset.ad,
  45 + id: e.currentTarget.dataset.id
  46 + })
  47 + wx.navigateBack({
  48 + delta: 1
  49 + })
  50 + },
  51 +
  52 + // 设置默认地址
  53 + mrAddressFun(e) {
  54 + let t = this
  55 + let index = e.currentTarget.dataset.index
  56 + let u = a.interface.mraddress;
  57 + let d = {
  58 + id: e.currentTarget.dataset.id,
  59 + mo: 1
  60 + }
  61 + a.post(u, d).then((r) => {
  62 + if (r.code == 200) {
  63 + t.setData({
  64 + [`list[${index}].check`]: true
  65 + })
  66 + wx.showToast({
  67 + title: '设置成功',
  68 + icon: 'none',
  69 + duration: 1300
  70 + })
  71 + setTimeout(() => {
  72 + t.getListFun()
  73 + }, 1300)
  74 + }
  75 + }).catch((er) => {
  76 + })
  77 + },
  78 +
  79 + // 修改地址
  80 + editAddressFun(e) {
  81 + wx.navigateTo({
  82 + url: '/pages/address/edit_address/edit_address?id=' + e.currentTarget.dataset.id,
  83 + })
  84 + },
  85 +
  86 + // 删除地址
  87 + delAddressFun(e) {
  88 + let t = this;
  89 + let u = a.interface.deladdress;
  90 + let d = {
  91 + id: e.currentTarget.dataset.id
  92 + }
  93 + a.post(u, d).then((r) => {
  94 + if (r.code == 200) {
  95 + wx.showToast({
  96 + title: '删除成功',
  97 + icon: 'none',
  98 + duration: 1300
  99 + })
  100 + setTimeout(() => {
  101 + t.getListFun()
  102 + }, 1300)
  103 + }
  104 + }).catch((er) => {
  105 + })
  106 + },
  107 +
  108 + // 新增地址
  109 + addFun() {
  110 + wx.navigateTo({
  111 + url: '/pages/address/add_address/add_address',
  112 + })
  113 + },
  114 +
  115 + /**
  116 + * 生命周期函数--监听页面初次渲染完成
  117 + */
  118 + onReady: function() {
  119 +
  120 + },
  121 +
  122 + /**
  123 + * 生命周期函数--监听页面显示
  124 + */
  125 + onShow: function() {
  126 + this.getListFun()
  127 + },
  128 +
  129 + /**
  130 + * 生命周期函数--监听页面隐藏
  131 + */
  132 + onHide: function() {
  133 +
  134 + },
  135 +
  136 + /**
  137 + * 生命周期函数--监听页面卸载
  138 + */
  139 + onUnload: function() {
  140 +
  141 + },
  142 +
  143 + /**
  144 + * 页面相关事件处理函数--监听用户下拉动作
  145 + */
  146 + onPullDownRefresh: function() {
  147 +
  148 + },
  149 +
  150 + /**
  151 + * 页面上拉触底事件的处理函数
  152 + */
  153 + onReachBottom: function() {
  154 +
  155 + },
  156 +
  157 + /**
  158 + * 用户点击右上角分享
  159 + */
  160 + onShareAppMessage: function() {
  161 +
  162 + }
  163 +})
  1 +{
  2 + "navigationBarTitleText": "我的地址"
  3 +}
  1 +<view class="content">
  2 + <view class="item" wx:for="{{list}}" wx:key data-id="{{item.id}}" data-n="{{item.name}}" data-tel="{{item.tel}}" data-a="{{item.area}}" data-ad="{{item.address}}" bindtap="selectAdddressFun">
  3 + <view class="user_info">
  4 + <view class="name">{{item.name}}</view>
  5 + <view class="tel">{{item.tel}}</view>
  6 + <view class="type" wx:if="{{item.mo == 1}}">默认</view>
  7 + </view>
  8 + <view class="address">
  9 + {{item.area}} {{item.address}}
  10 + </view>
  11 + <view class="btn_box">
  12 + <view class="check" data-id="{{item.id}}" data-index="{{index}}" wx:if="{{item.mo != 1}}" catchtap="mrAddressFun">
  13 + <image wx:if="{{!item.check}}" src="/images/check.png" />
  14 + <image wx:else src="/images/check@.png" /> 设为默认地址
  15 + </view>
  16 + <block>
  17 + <view class="btn_item" data-id="{{item.id}}" catchtap="editAddressFun">
  18 + <image src="/images/icon_60.png" style="width: 26rpx;height: 26rpx;" />编辑
  19 + </view>
  20 + <view class="btn_item" data-id="{{item.id}}" catchtap="delAddressFun">
  21 + <image src="/images/icon_48.png" />删除
  22 + </view>
  23 + </block>
  24 + </view>
  25 + </view>
  26 + <view class="empty" wx:if="{{list.length==0}}">暂无地址信息,请去添加</view>
  27 +
  28 +</view>
  29 +
  30 +<view class="add_btn_box">
  31 + <view class="add_btn" bindtap="addFun">+ 添加收货地址</view>
  32 +</view>