小程序嵌套处理

<view class="selectsize_content">
<block wx:for="{{properties}}" wx:key="item" wx:for-index="id">
<view class="content_title">{{item.name}}</view>
<view class='content_list'>
<block wx:for="{{item.childsCurGoods}}" wx:key="items">
<text class="{{ item.isSelect?'active':''}}" data-select-index="{{id}}" data-attr-index="{{index}}" data-content="{{properties}}" bindtap='clickMenu'>{{item.name}}</text>
</block>
</view>
</block>
</view>


作者:zlf_j
链接:https://www.jianshu.com/p/b86a995d24fd
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

css

.selectsize_content{
width:100%;
height:450rpx;
border-bottom:2rpx solid lightgray;
}
.content_title{
line-height:100rpx;
margin-left:20rpx;
}
.content_list{
line-height:100rpx;
margin-left:20rpx;
}
.content_list text{
padding:20rpx;
border:2rpx solid lightgray;
margin-right:20rpx;
}
// 商品属性选中后
.active{
border-color:red;
color:red;
}



作者:zlf_j
链接:https://www.jianshu.com/p/b86a995d24fd
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
https://www.cnblogs.com/stoneniqiu/p/9260706.html

02.获取用户登录信息

这个功能一开始是好的,过了几天不知道怎么就获取不到用户信息了。然后按照文档意思,需要让用户再次点击button授权才可以。

复制代码
<view wx:if="{{isAuth}}" class="container short">
    <view class='avatar-box'>
    <image class="user-avatar"  src="{{ userInfo.avatarUrl }}"  />
    </view>
    <text class="title">{{ userInfo.nickName }}</text>
</view>
 <button  wx:if="{{!isAuth}}"  open-type="getUserInfo">授权登录</button>
复制代码

isAuth是加载的时候判断有没有 res.authSetting['scope.userInfo'] 这个权限,没有就为false。这样才能再次获取用户信息。

03.图片自适应

一开始在页面怎么调整css,图片的宽高比都失真,无奈之余去看了才晓得,这个居然也有暗门。

<image class="img" bindtap="previewImage" src="images/actv.jpg" mode="widthFix">

需要加上mode才能自适应。这真是伤悲,为啥不是默认配置。

04.拨打电话

  call:function(){
    wx.makePhoneCall({
      phoneNumber: phone 
    })
  },

这个功能实用,直接跳转到用户手机拨打电话的界面

posted @ 2018-07-02 11:40  小毛驴  阅读(399)  评论(0编辑  收藏  举报