Commit e7927409 by jscat

nyx weapp: 数据优化, 页面优化

1. 更新my-orders 的页面和测试数据
parent f8740917
//config.js API全局域名配置
//config.js API全局域名配置
//config.js API全局域名配置
var prod = 0; //阿里云服务器生产版本
var local = 1; //本地java测试,需要启动java 后台
var test = 0; //阿里云服务器测试版本
var local = 0; //本地java测试,需要启动java 后台
var test = 1; //阿里云服务器测试版本
var debug = 0; //是否打印调试信息
var host_key = "https://fun.hisuhong.com";
......
<view class="page">
<view class="page">
......@@ -39,12 +39,12 @@
<text>积分</text>
</view>
<!-- todo 0728 热销暂时也不实现 -->
<!-- <view class="items">
<navigator url="matchStudyDetail/matchStudyDetail?studyType=wset3">
<image src="../../icon/activity/top.png"></image>
<view class="items">
<navigator url="/pages/my/my-orders/my-orders">
<image src="../../icon/my/activity.png"></image>
</navigator>
<text>热销</text>
</view> -->
<text>预订</text>
</view>
</view>
</view>
......
/*
/*
......@@ -93,7 +93,7 @@
text-align: center;
line-height: 38px;
font-size: 28rpx;
color: #F00;
color: #FF6600;
font-weight: bold;
}
.writer image{
......
// pages/my/my-order/my-order.js
// pages/my/my-order/my-order.js
var config = wx.getStorageSync("config");
var app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
//用户信息初始化
nyxCode: "",
authStatus: "",
userInfo: {},
//活动列表
orders : [],
//活动信息
orderInfo_2 : {
member_name : "Renaissance Bar",
title : "酒市集",
total_price : 149.00,
order_id : "oid_123",
order_status : "交易成功",
product_image : "https://930-test-sh.oss-cn-shanghai.aliyuncs.com/user-dir/sakura.jpg",
order_qrcode : "https://930-test-sh.oss-cn-shanghai.aliyuncs.com/qrcode-dir/mid_11235813.png",
item_height : 130 + 20 + 120*2 + 30*3, // basic + margin-bottom(20rpx) + item(n) + margin(n+1)
order_item :[
{
product_desc :"会员",
unit_price : "59.00",
quantity : 1,
},
{
product_desc :"普通用户",
unit_price : "99.00",
quantity : 1,
}
]
},
orderInfo_1 : {
member_name : "Renaissance Bar",
title : "酒市集",
total_price : 149.00,
order_id : "oid_123",
order_status : "交易成功",
product_image : "https://930-test-sh.oss-cn-shanghai.aliyuncs.com/user-dir/sakura.jpg",
order_qrcode : "https://930-test-sh.oss-cn-shanghai.aliyuncs.com/qrcode-dir/mid_11235813.png",
item_height : 130 + 20 + 120 + 30*2, // 控制item的高度
order_item :[
{
product_desc :"普通用户",
unit_price : "99.00",
quantity : 1,
}
]
},
orderInfo_3 : {
member_name : "Renaissance Bar",
title : "酒市集",
total_price : 149.00,
order_id : "oid_123",
order_status : "交易成功",
product_image : "https://930-test-sh.oss-cn-shanghai.aliyuncs.com/user-dir/sakura.jpg",
order_qrcode : "https://930-test-sh.oss-cn-shanghai.aliyuncs.com/qrcode-dir/mid_11235813.png",
item_height : 130 + 20 + 120*3 + 30*4, // 控制item的高度
order_item :[
{
product_desc :"普通用户",
unit_price : "99.00",
quantity : 1,
},
{
product_desc :"普通用户",
unit_price : "99.00",
quantity : 2,
},
{
product_desc :"普通用户",
unit_price : "99.00",
quantity : 3,
},
]
},
//选中barcode的qrcode和url
qrcode : "",
qrcode_url : "",
// {
// rankId : "rid_001",
// defaultType : "1",
// matchType : "竞答",
// title : "泥煤怪兽",
// rank : "1",
// score : "200",
// ratio : "96%",
// },
isHideLoadMore: false,
/* 模态框 */
showModalPoints: false,
showModalBarcode : false,
/* 订单 可使用/不可用状态 */
selectTab : true,
matchStatus : "",
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var _this = this;
wx.setNavigationBarTitle({
title: '我的预订',
})
//初始化数据
if (wx.getStorageSync('nyxCode')) {
_this.setData({
nyxCode: wx.getStorageSync('nyxCode'),
userInfo: wx.getStorageSync('userInfo'),
authStatus: wx.getStorageSync('authStatus'),
matchSeason: wx.getStorageSync('matchSeason'),
})
}
//初始载入四个积分
if(_this.__data__.orders.length == 0)
{
//getPoints(scrollType, pageNum, pageCount, matchStatus)
//onLoad的时候展示可使用的积分
var orders = []
orders.push(_this.__data__.orderInfo_2)
orders.push(_this.__data__.orderInfo_3)
orders.push(_this.__data__.orderInfo_1)
//_this.getPoints(0, 1, 4, matchStatus);
_this.setData({
orders : orders,
selectTab : '20', // 默认为可使用 tab
isHideLoadMore : orders.length < 4 ? true : false,
})
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
console.log('页面上拉触底')
var _this = this;
var matchStatus = _this.__data__.matchStatus
var isHideLoadMore = _this.__data__.isHideLoadMore;
var pageIndex = _this.__data__.pageIndex;
//控制逻辑, 在onClick之后或者onGetComment事件之后再允许下拉更新操作
//判断是否已经全部加载完毕
//没有则加载更多
if (!isHideLoadMore) {
console.log('加载更多')
setTimeout(() => {
_this.getPoints(1, pageIndex, 4, matchStatus);
}, 1000)
}
else {
console.log('没有更多')
}
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
// 用户自定义函数
/*
*/
/* 点击好友助力 */
onClickPoints: function(e){
var _this = this;
var indexId = e.currentTarget.dataset.id
var match_id = _this.__data__.points[indexId].match_id
_this.getBonus(match_id)
    _this.setData({
      showModalPoints: true
    })
},
/* 点击barcode */
onClickBarcode: function(e){
var _this = this;
//指明具体是list的哪一个item
var indexId = e.currentTarget.dataset.id
var qrcode_url = _this.__data__.points[indexId].qrcode_url
var qrcode = _this.__data__.points[indexId].match_id
    this.setData({
      showModalBarcode : true,
qrcode : qrcode,
qrcode_url : qrcode_url
    })
},
  // 弹出层里面的弹窗
  ok: function () {
    this.setData({
      showModalPoints: false,
showModalBarcode: false
    })
  },
/**
* tab切换
*/
tab: function(e) {
var _this = this;
//js的e.currentTarget.id 对应wxml的 id="tab0"
//js的e.currentTarget.dataSet.id 对应wxml的 data-id="tab0"
var id = e.currentTarget.id;
var dataId = e.currentTarget.dataset.id
_this.setData({
selectTab: dataId,
})
},
/**
* 用户自定义函数
*
*/
// 获取points数据
// scrollType: 是否是翻页, 0-不翻页 | 1-翻页
getPoints: function (scrollType, pageNum, pageCount, memberStatus) {
var _this = this;
var query_url = '&matchStatus='+memberStatus
var strUrl = config.match_query_url + "?pageCount=" + pageCount
+ "&pageNum=" + pageNum + query_url
config.debug == 1 ? console.log("===strUrl is: \"" + strUrl + "\"") : ""
wx.request({
url: strUrl,
method: 'GET',
header: {
'Cookie': wx.getStorageSync('cookieKey'),
},
success: function (res) {
if (res.data.resultCode == 200) {
//表示HTTP请求成功
console.log(res.data);
var list = []
var bisHideLoadMoreType = false;
if (res.data.data.length < pageCount) {
bisHideLoadMoreType = true;
}
for (var i = 0; i < res.data.data.length; i++) {
var result = {}
result["total_point"] = res.data.data[i].totalPoint
result["member_name"] = res.data.data[i].memberName
result["bonus_count"] = res.data.data[i].bonusCount
result["bonus_point"] = res.data.data[i].bonusPoint
result["match_id"] = res.data.data[i].matchId
result["qrcode_url"] = res.data.data[i].qrcodeUrl
list.push(result)
}
//进行翻页设置(加载更多)
if (scrollType == 1) {
var pointsList = _this.__data__.points;
list = pointsList.concat(list)
}
_this.setData({
points: list,
pageIndex: pageNum + 1,
isHideLoadMore: bisHideLoadMoreType,
})
}
}
})
},
// 获取bonus points数据
getBonus: function (matchId) {
var _this = this;
var query_url = '?matchId='+matchId
var strUrl = config.bonus_query_url + query_url
config.debug == 1 ? console.log("===strUrl is: \"" + strUrl + "\"") : ""
wx.request({
url: strUrl,
method: 'GET',
header: {
'Cookie': wx.getStorageSync('cookieKey'),
},
success: function (res) {
if (res.data.resultCode == 200) {
//表示HTTP请求成功
console.log(res.data);
var list = []
for (var i = 0; i < res.data.data.length; i++) {
var result = {}
result["match_id"] = res.data.data[i].matchId
result["user_name"] = res.data.data[i].userName
result["bonus_point"] = res.data.data[i].bonusPoint
list.push(result)
}
_this.setData({
bonus_info: list,
})
}
}
})
},
})
\ No newline at end of file
<view class="page">
<view class="page">
<!-- Tab: refer to 有品·优惠券 -->
<view class="weui-flex" style="height: 120rpx;">
<view class="weui-flex__item weui-flex justify align border" data-id="20" id="id-20" bindtap="tab">
<view class="placeholder">
<text class="text {{selectTab=='20'?'selected':''}}">可使用</text>
</view></view>
<view class="weui-flex__item weui-flex justify align border" data-id="10" id="id-10" bindtap="tab">
<view class="placeholder">
<text class="text {{selectTab=='10'?'selected':''}}">代付款</text>
</view></view>
<view class="weui-flex__item weui-flex justify align border" data-id="00::30" id="id-00::30" bindtap="tab">
<view class="placeholder">
<text class="text {{selectTab=='00::30'?'selected':''}}">不可用</text>
</view></view>
</view>
<!-- Content: refer to 有品·优惠券 + 点评(可使用) -->
<view class="coupon-list" wx:for="{{orders}}" wx:for-item="item" wx:key="{{index}}">
<view class="item stamp stamp01" style="height:{{item.item_height}}rpx;">
<!-- 商家信息 -->
<view class="note-info">
<view class="note-title" style="font-weight: bold">
<view class="title-left">{{item.member_name}}</view>
<view class="title-right" bindtap="onClickBarcode" data-id='{{index}}'>
<image src="../../../icon/my/logo-barcode.png"></image>
</view>
</view>
</view>
<!-- 商品信息 -->
<block wx:for="{{item.order_item}}" wx:for-item="sub_item" wx:key="{{index}}">
<view class="note-row">
<image class="writer-image" src="{{item.product_image}}"/>
<view class="note-column">
<span>{{sub_item.product_desc}} {{sub_item.unit_price}}</span>
<span> x {{sub_item.quantity}}</span>
</view>
</view>
</block>
<view class="note-price" style="font-weight: bold">
<span>总价: ¥{{item.total_price}}</span>
</view>
</view>
</view>
<!-- 加载更多 -->
<view class="weui-loadmore" hidden="{{isHideLoadMore}}">
<view class="weui-loading"></view>
<view class="weui-loadmore__tips">正在加载</view>
</view>
<view class="weui-loadmore" hidden="{{!isHideLoadMore}}">
<view class="weui-loadmore__tips">没有更多啦 {{'>'}}_{{'<'}} </view>
</view>
<!-- 查看好友助力-->
<!-- 微信小程序自定义弹框 https://blog.csdn.net/qq_39702981/article/details/85104827 -->
<!-- 微信小程序自定义弹框 https://blog.csdn.net/qq_39702981/article/details/85320926 -->
<!-- start 遮罩层 -->
<view class="mask" catchtouchmove="preventTouchMove" wx:if="{{showModalPoints}}"></view>
<!-- 弹出层 -->
<view class="modalDlg" wx:if="{{showModalPoints}}">
<!-- 二维码或其他图片 -->
<view class="title">
<text style="color:#666666">助力清单</text>
</view>
<view class="title-close" bindtap="ok">
<image src="../../../icon/close.png"></image>
</view>
<view class="list-point">
<view class="text" wx:for="{{bonus_info}}" wx:for-item="item" wx:key="{{index}}" >
{{item.user_name}}助力{{item.bonus_point}}积分
</view>
</view>
</view>
<!-- end 遮罩层 -->
<!-- 查看优惠券码-->
<!-- 微信小程序自定义弹框 https://blog.csdn.net/qq_39702981/article/details/85104827 -->
<!-- 微信小程序自定义弹框 https://blog.csdn.net/qq_39702981/article/details/85320926 -->
<!-- start 遮罩层 -->
<view class="mask" catchtouchmove="preventTouchMove" wx:if="{{showModalBarcode}}"></view>
<!-- 弹出层 -->
<view class="modalDlg" wx:if="{{showModalBarcode}}">
<!-- 二维码或其他图片 -->
<view class="title">
<text style="color:#666666">请扫描以下券码验券 </text>
</view>
<view class="title-right" bindtap="ok">
<image src="../../../icon/close.png"></image>
</view>
<view class="list-barcode">
<view class="text">券码:{{qrcode}}</view>
<image src="{{qrcode_url}}"></image>
</view>
<view class="list-barcode-image">
</view>
</view>
<!-- end 遮罩层 -->
</view>
\ No newline at end of file
<view class="page">
<view class="page">
......@@ -30,5 +30,12 @@
<view class="weui-cell__bd">我的积分</view>
<view class="weui-cell__ft weui-cell__ft_in-access"></view>
</navigator>
<navigator class="weui-cell weui-cell_access" hover-class="weui-cell_active" url="/pages/my/my-orders/my-orders">
<view class="weui-cell__hd">
<image src="/icon/my/activity.png" />
</view>
<view class="weui-cell__bd">我的预订</view>
<view class="weui-cell__ft weui-cell__ft_in-access"></view>
</navigator>
</view>
</view>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论