wangxin vor 6 Jahren
Ursprung
Commit
7b697b7007

+ 58 - 0
components/authdialog/index.js

@@ -0,0 +1,58 @@
+Component({
+  options: {
+    multipleSlots: true // 在组件定义时的选项中启用多slot支持
+  },
+  /**
+   * 组件的属性列表
+   */
+  properties: {
+    // 弹窗标题
+    title: {
+      type: String,
+      value: '标题' // 默认值
+    },
+    // 弹窗内容
+    content: {
+      type: String,
+      value: '弹窗内容'
+    },
+
+    // 弹窗确认按钮文字
+    confirmText: {
+      type: String,
+      value: '确定'
+    }
+  },
+
+  /**
+   * 组件内私有数据
+   */
+  data: {
+    // 弹窗显示控制
+    isShow: false
+  },
+
+  /**
+   * 组件的公有方法列表
+   */
+  methods: {
+
+    //隐藏弹框
+    hideDialog() {
+      this.setData({
+        isShow: !this.data.isShow
+      })
+    },
+    //展示弹框
+    showDialog() {
+      this.setData({
+        isShow: !this.data.isShow
+      })
+    },
+
+    confirmEvent() {
+      this.hideDialog();
+    }
+
+  }
+})

+ 4 - 0
components/authdialog/index.json

@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

+ 10 - 0
components/authdialog/index.wxml

@@ -0,0 +1,10 @@
+<view class='dialog-container' hidden="{{!isShow}}">
+    <view class='dialog-mask'></view>
+    <view class='dialog-info'>
+        <view class='dialog-title'>{{ title }}</view>
+        <view class='dialog-content'>{{ content }}</view>
+        <view class='dialog-footer'>
+          <button class='dialog-btn' open-type="openSetting" catchtap='confirmEvent'>{{ confirmText }}</button>
+        </view>
+    </view>
+</view>

+ 50 - 0
components/authdialog/index.wxss

@@ -0,0 +1,50 @@
+.dialog-mask{
+  position: fixed;
+    z-index: 1000;
+    top: 0;
+    right: 0;
+    left: 0;
+    bottom: 0;
+    background: rgba(0, 0, 0, 0.3);
+}
+.dialog-info{
+    position: fixed;
+    z-index: 5000;
+    width: 80%;
+    max-width: 600rpx;
+    top: 50%;
+    left: 50%;
+    -webkit-transform: translate(-50%, -50%);
+    transform: translate(-50%, -50%);
+    background-color: #FFFFFF;
+    text-align: center;
+    border-radius: 3px;
+    overflow: hidden;
+}
+.dialog-title{
+    font-size: 36rpx;
+    padding: 30rpx 30rpx 10rpx;
+}
+.dialog-content{
+    padding: 10rpx 30rpx 20rpx;
+    min-height: 80rpx;
+    font-size: 32rpx;
+    line-height: 1.3;
+    word-wrap: break-word;
+    word-break: break-all;
+    color: #999999;
+}
+.dialog-footer{
+    display: flex;
+    align-items: center;
+    position: relative;
+    line-height: 90rpx;
+    font-size: 34rpx;
+}
+.dialog-btn{
+    display: block;
+    -webkit-flex: 1;
+    flex: 1;
+    position: relative;
+    color: #3CC51F;
+}

+ 14 - 5
dever/core.js

@@ -73,17 +73,26 @@ var dever =
       this.set(self, 'list', value);
     }
 
-    //设置模板变量
-    , setView: function (self, value) {
-      this.set(self, 'view', value);
-    }
-
     //设置模板变量
     ,sets: function (self, data) {
       this.log('data', data);
       self.setData(data);
     }
 
+    //列表分页追加
+    , appendList: function (self, value) {
+      var list = self.data.list;
+      for(var i=0; i<value.length; i++){
+        list.push(value[i]); 
+      }
+      this.setList(self, list);
+    }
+
+    //设置模板变量
+    , setView: function (self, value) {
+      this.set(self, 'view', value);
+    }
+
     //获取包
     ,package : function(name)
     {

BIN
static/img/cash.png


BIN
static/img/item-1.png


BIN
static/img/item-2.png


BIN
static/img/item-right.png


BIN
static/img/location.png


BIN
static/img/location2.png


+ 10 - 13
template/carts/index.js

@@ -1,18 +1,20 @@
 // template/carts/index.js
 Page({
   dever: getApp().dever,
-  addrObj: null,
+  authdialog: null,
   data: {
-    
+    isUseAddress: false
   },
 
   onLoad: function (options) {
     // 初始化购物车
     //self.dever.carts(self, 'carts.save', 'carts/index');
 
+    this.authdialog = this.selectComponent("#authdialog");
+
     //test - begin
     var list = new Array();
-    for(var i=1; i<10; i++){
+    for(var i=1; i<2; i++){
       var item = new Object();
       item.name = i+'盒有机韭菜';
       item.price = i*20;
@@ -37,14 +39,6 @@ Page({
       }
     })
   },
-
-  /**
-   * 页面上拉触底事件的处理函数
-   */
-  onReachBottom: function () {
-  
-  },
-
   /**
    * 使用微信地址
    */
@@ -54,8 +48,8 @@ Page({
       wx.chooseAddress({
         success: function (res) {
           that.dever.log('wx.chooseAddress', res);
-          that.addrObj = res;
-          that.sets(that, res);
+          that.dever.set(that,'addrObj', res);
+          that.dever.set(that,'isUseAddress', true);
         },
         fail: function (res) {
           that.dever.log('wx.chooseAddress', 'fail');
@@ -71,6 +65,9 @@ Page({
             scope: 'scope.address',
             success: function () {
               success();
+            },
+            fail: function(res){
+              that.authdialog.showDialog();
             }
           })
         }

+ 4 - 1
template/carts/index.json

@@ -1,3 +1,6 @@
 {
-  "navigationBarTitleText": "农小盒"
+  "navigationBarTitleText": "农小盒",
+  "usingComponents": {
+    "authdialog": "/components/authdialog/index"
+  }
 }

+ 17 - 3
template/carts/index.wxml

@@ -1,8 +1,21 @@
 <view class='top'>
-  <view class='address'>
-    <view>{{address}}</view>
+  <view class='address' bindtap='chooseAddress'>
+    <!--<view>{{address}}</view>
     <text class='tips'>填写收货地址</text>
-    <button class='nxh__button' bindtap='chooseAddress' >使用微信地址</button>
+    <button class='nxh__button' bindtap='chooseAddress' >使用微信地址</button>-->
+    <image class='left' src='/static/img/location2.png'></image>
+    <view class='center' wx:if='{{isUseAddress}}'>
+      <text>{{addrObj.userName}}</text>
+      <text>{{addrObj.provinceName+addrObj.cityName+addrObj.countyName+addrObj.detailInfo}}</text>
+      <text>{{addrObj.telNumber}}</text>
+    </view>
+    <view class='tips' wx:else><text>使用微信地址</text></view>
+    <image class='right' src='/static/img/item-right.png'></image>
+    <authdialog id='authdialog' 
+      title='授权提示' 
+      content='小程序需要您的授权才能提供更好的服务哦'
+      confirmText='知道了'>
+    </authdialog>
   </view>
   <view class='order' wx:for='{{list}}' wx:key='{{index}}' bindlongtap='delOrder'>
     <text class='title'>{{item.name}}</text>
@@ -14,6 +27,7 @@
         <image class='add' src='/static/img/carts-add.png'></image>
       </view>
     </view>
+    <view class='split_line'/>
   </view>
 </view>
 <view class='bottom'>

+ 40 - 11
template/carts/index.wxss

@@ -3,38 +3,67 @@
   flex-direction: column;
   justify-items: center;
   text-align: center;
-  margin-bottom: 120rpx;
+  margin-bottom: 100rpx;
 }
 .address {
-  padding: 40rpx 30rpx 30rpx 30rpx;
+  padding: 40rpx 50rpx 30rpx 50rpx;
   border-bottom: 5px solid #FBFBFB;
+  display: flex;
+  flex-direction: row;
+  align-items: center;
+}
+.address .left {
+  width: 50rpx;
+  height: 50rpx;
+}
+.address .center{
+  display: flex;
+  flex-direction: column;
+  flex-grow: 1;
+  padding: 0 20rpx 0 20rpx;
+}
+.address .center text {
+  display: flex;
+  justify-content: left;
+  flex-wrap: wrap;
+}
+.address .right{
+  width: 50rpx;
+  height: 50rpx;
 }
 .tips {
-  color: #ccc;
-  font-size: 30rpx;
+  flex-grow: 1;
+  padding-left: 20rpx;
+}
+.tips text {
+  display: flex;
+  justify-content: left;
+  color: #707070;
+  font-size: 35rpx;
 }
-.nxh__button {
+/*.nxh__button {
   background: #fff;
   border:1rpx solid #539804;
   color: #539804;
   margin-top: 6rpx;
   font-size: 30rpx;
   width: 300rpx;
-}
-.order {
-  padding: 40rpx 50rpx 30rpx 50rpx;
-  border-bottom: 1px solid #FBFBFB;
+}*/
+.order .split_line {
+  margin:0 20rpx 0 30rpx;
+  border-bottom: 1px solid #E5E5E5;
 }
 .order .title {
   display: flex;
   justify-content: left;
   font-size: 35rpx;
-  margin-bottom: 25rpx;
+  margin:40rpx 50rpx 25rpx 50rpx;
 }
 .order .oper {
   display: flex;
   flex-direction: row;
   justify-content: space-between;
+  margin: 0 50rpx 25rpx 50rpx;
 }
 .order .price {
   color: #666666;
@@ -55,7 +84,7 @@
 }
 .bottom {
   width: 750rpx;
-  height: 119rpx;
+  height: 100rpx;
   position: fixed;
   bottom: 0;
   display: flex;

+ 12 - 3
template/home/index.js

@@ -1,17 +1,25 @@
 Page({
   dever: getApp().dever,
+  pg: 1,
   data: {
-      test : 1
+      
   },
   onLoad: function (options) {
     var that = this;
     var sign = that.dever.getLoginInfo() != null ? that.dever.getLoginInfo().signature : '';
     that.dever.request('product.api.home', {
+      json: 1,
+      pg: that.pg,
       signature: sign
     },{
         success: function (data, res) {
-          that.dever.setList(that, data.product);
+          if(that.pg > 1){
+            that.dever.appendList(that, data.product);
+          }else{
+            that.dever.setList(that, data.product);
+          }
           that.dever.stopPullDown();
+          that.pg++;
         }
     });
   },
@@ -49,6 +57,7 @@ Page({
   },
 
   onPullDownRefresh: function () {
+    this.pg = 1;
     this.dever.startPullDown(this);
   },
 
@@ -56,6 +65,6 @@ Page({
    * 页面上拉触底事件的处理函数
    */
   onReachBottom: function () {
-    //TODO 
+    this.dever.startPullDown(this);
   },
 })

+ 3 - 2
template/home/index.wxml

@@ -4,10 +4,11 @@
         <view class="page__title">{{item.name}}</view>
         <view class="page__desc">
           <text class="price">¥ {{item.price}}</text>
-          <view class="button" catchtap='doBuy' data-id="{{item.id}}" data-name="{{item.name}}"><button class="nxh__button" type="primary" size="mini">购买</button></view>
+          <view class="button" catchtap='doBuy' data-id="{{item.id}}" data-name="{{item.name}}"><button class="nxh__button nxh__button2" size="mini">购买</button></view>
         </view>
     </view>
     <view class='cash'>
-      <image src='/static/img/cash.png'></image>
+      <button class='nxh__button nxh__button3' open-type="contact">在线客服</button>
+      <button class='nxh__button nxh__button3'>礼品卡兑换</button>
     </view>
 </view>

+ 12 - 10
template/home/index.wxss

@@ -5,7 +5,7 @@
 {
   border-radius: 5px;
   box-shadow: 0rpx 3rpx 5rpx #DBDBDB;
-  margin: 30rpx 30rpx 0 30rpx;
+  margin: 30rpx 30rpx 120rpx 30rpx;
   padding: 0rpx;
   overflow: hidden;
 }
@@ -33,18 +33,20 @@
   color:#ff9900; 
 }
 
-.nxh__button
-{
+.nxh__button2{
   width: 180rpx;
 }
+.nxh__button3 {
+  width: 300rpx;
+}
 .cash {
   position: fixed;
-  bottom: 30rpx;
-  right: 325rpx;
-}
-.cash image {
-  width: 100rpx;
-  height: 100rpx;
+  bottom: 0rpx;
+  height: 120rpx;
+  width: 100%;
   background: #fff;
-  border-radius: 50rpx;
+  display: flex;
+  flex-direction: row;
+  justify-content: space-around;
+  align-items: center;
 }

+ 29 - 13
template/view/index.js

@@ -2,24 +2,27 @@ Page({
   dever: getApp().dever,
   product: null,
   data: {
-    content: ""
+    content: "",
+    product_id: ''
   },
 
   onLoad: function (options) {
     var that = this;
-    var callback = {
-      success: function (data, res) {
-        that.product = data.product;
-        var temp = that.dever.html('content', data.product.content, that);
-        that.setData({
-          content: temp
-        })
-      }
-    }
+    that.setData({
+      id: options.id 
+    });
     that.dever.request('product.api.view',{
       signature: '',
       id: options.id
-    }, callback);
+    }, {
+        success: function (data, res) {
+          that.product = data.product;
+          var temp = that.dever.html('content', data.product.content, that);
+          that.setData({
+            content: temp
+          })
+        }
+    });
   },
 
   /**
@@ -41,8 +44,21 @@ Page({
   /**
    * 立即购买
    */
-  doBuy: function(){
-
+  doBuy: function(event){
+    var that = this;
+    var id;
+    if (typeof (event) == 'object') {
+      id = event.currentTarget.dataset.id
+    } else {
+      id = event
+    }
+    this.dever.isLogin(function (res) {
+      if (res) {
+        that.dever.location('carts/index?id=' + id);
+      } else {
+        that.dever.location('login/index');
+      }
+    });
   }
 
 })

+ 1 - 1
template/view/index.wxml

@@ -7,5 +7,5 @@
 </view>
 <view class='bottom'>
   <button class='nxh__button' open-type='share'>分享给好友</button>
-  <button class='nxh__button' bindtap='doBuy'>立即购买</button>
+  <button class='nxh__button' bindtap='doBuy' data-id="{{product_id}}">立即购买</button>
 </view>