|
@@ -6,8 +6,38 @@ Page({
|
|
|
isShowNull: false
|
|
|
},
|
|
|
onLoad: function (options) {
|
|
|
- var that = this;
|
|
|
- if(that.pg == 1){
|
|
|
+ if(this.dever.getSignature() == ''){
|
|
|
+ var that = this;
|
|
|
+ wx.login({
|
|
|
+ success: function (res) {
|
|
|
+ if (res.code) {
|
|
|
+ that.dever.request("passport.applet.bind", {
|
|
|
+ json: 1,
|
|
|
+ code: res.code
|
|
|
+ }, {
|
|
|
+ success: function (data, res) {
|
|
|
+ that.dever.saveLoginInfo(data);
|
|
|
+ that.getHomeData(that);
|
|
|
+ },
|
|
|
+ fail: function (res) {
|
|
|
+ that.dever.log('wx.login', JSON.stringify(res));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ that.dever.log('wx.login', res.errMsg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ this.getHomeData(this);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ * 获取首页数据
|
|
|
+ */
|
|
|
+ getHomeData: function(that){
|
|
|
+ if (that.pg == 1) {
|
|
|
that.dever.showLoading();
|
|
|
}
|
|
|
that.cashdialog = this.selectComponent("#cashdialog");
|
|
@@ -16,22 +46,22 @@ Page({
|
|
|
json: 1,
|
|
|
pg: that.pg,
|
|
|
signature: that.dever.getSignature()
|
|
|
- },{
|
|
|
+ }, {
|
|
|
success: function (data, res) {
|
|
|
- if (data.product.length > 0){
|
|
|
- if(that.pg > 1){
|
|
|
+ if (data.product.length > 0) {
|
|
|
+ if (that.pg > 1) {
|
|
|
that.dever.appendList(that, data.product);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
that.dever.setList(that, data.product);
|
|
|
}
|
|
|
that.pg++;
|
|
|
that.dever.set(that, 'isShowNull', false);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
that.dever.set(that, 'isShowNull', true);
|
|
|
}
|
|
|
that.dever.hideLoading();
|
|
|
}
|
|
|
- });
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
|
|
@@ -53,7 +83,7 @@ Page({
|
|
|
var that = this;
|
|
|
this.dever.isLogin(function (res) {
|
|
|
if (res) {
|
|
|
- that.cashdialog.setErrMsg(true, '');
|
|
|
+ that.cashdialog.setErrMsg('');
|
|
|
that.cashdialog.showDialog();
|
|
|
} else {
|
|
|
that.dever.location('login/index');
|
|
@@ -69,7 +99,7 @@ Page({
|
|
|
var cashCode = this.cashdialog.getCashCode();
|
|
|
|
|
|
if (cashCode.length <= 0) {
|
|
|
- that.cashdialog.setErrMsg(false, '请输入兑换码!');
|
|
|
+ that.cashdialog.setErrMsg('请输入兑换码!');
|
|
|
return ;
|
|
|
}
|
|
|
that.dever.request('product.api.checkCode', {
|
|
@@ -83,7 +113,7 @@ Page({
|
|
|
},
|
|
|
fail: function (res) {
|
|
|
that.dever.log('product.api.checkCode', res);
|
|
|
- that.cashdialog.setErrMsg(false, res.data.msg);
|
|
|
+ that.cashdialog.setErrMsg(res.data.msg);
|
|
|
}
|
|
|
});
|
|
|
},
|
|
@@ -103,6 +133,9 @@ Page({
|
|
|
});
|
|
|
},
|
|
|
|
|
|
+
|
|
|
+ * 页面下拉事件的处理函数
|
|
|
+ */
|
|
|
onPullDownRefresh: function () {
|
|
|
this.pg = 1;
|
|
|
this.dever.startPullDown(this);
|