|
@@ -53,6 +53,7 @@ Page({
|
|
|
var that = this;
|
|
|
this.dever.isLogin(function (res) {
|
|
|
if (res) {
|
|
|
+ that.cashdialog.setErrMsg(true, '');
|
|
|
that.cashdialog.showDialog();
|
|
|
} else {
|
|
|
that.dever.location('login/index');
|
|
@@ -64,12 +65,27 @@ Page({
|
|
|
* 跳转兑换页面
|
|
|
*/
|
|
|
toCash: function(){
|
|
|
- var code = this.cashdialog.getCashCode();
|
|
|
- this.dever.log('toCash code', code);
|
|
|
- if (code.length > 0) {
|
|
|
- this.dever.location('cash/index?code=' + code);
|
|
|
+ var that = this;
|
|
|
+ var cashCode = this.cashdialog.getCashCode();
|
|
|
+
|
|
|
+ if (cashCode.length <= 0) {
|
|
|
+ that.cashdialog.setErrMsg(false, '请输入兑换码!');
|
|
|
+ return ;
|
|
|
}
|
|
|
- this.cashdialog.hideDialog();
|
|
|
+ that.dever.request('product.api.checkCode', {
|
|
|
+ json: 1,
|
|
|
+ signature: that.dever.getSignature(),
|
|
|
+ code: cashCode
|
|
|
+ }, {
|
|
|
+ success: function (data, res) {
|
|
|
+ that.cashdialog.hideDialog();
|
|
|
+ that.dever.location('cash/index?code=' + cashCode);
|
|
|
+ },
|
|
|
+ fail: function (res) {
|
|
|
+ that.dever.log('product.api.checkCode', res);
|
|
|
+ that.cashdialog.setErrMsg(false, res.data.msg);
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
|
|
@@ -80,16 +96,7 @@ Page({
|
|
|
var id = event.currentTarget.dataset.id;
|
|
|
this.dever.isLogin(function(res){
|
|
|
if(res){
|
|
|
- that.dever.request('product.api.addCarts',{
|
|
|
- json: 1,
|
|
|
- signature: that.dever.getSignature(),
|
|
|
- product_id: id,
|
|
|
- num: 1
|
|
|
- },{
|
|
|
- success: function(data, res){
|
|
|
- that.dever.location('carts/index?id=' + id);
|
|
|
- }
|
|
|
- });
|
|
|
+ that.dever.location('view/index?id=' + id);
|
|
|
}else{
|
|
|
that.dever.location('login/index');
|
|
|
}
|