修复订单计算价格bug,添加首页推荐产品

This commit is contained in:
sugar1569 2019-02-14 11:27:51 +08:00
parent 13c13a3b07
commit c33f99a659
15 changed files with 339 additions and 117 deletions

View File

@ -6,7 +6,6 @@ use app\routine\model\routine\RoutineCode;
use app\routine\model\routine\RoutineFormId;
use app\routine\model\routine\RoutineTemplate;
use app\routine\model\store\StoreCombination;
use behavior\routine\RoutineBehavior;
use service\JsonService;
use service\GroupDataService;
use service\RoutineBizDataCrypt;
@ -14,10 +13,10 @@ use service\SystemConfigService;
use service\UploadService;
use service\UtilService;
use think\Request;
use behavior\wap\StoreProductBehavior;
use service\WechatTemplateService;
use service\CacheService;
use service\HookService;
use behavior\StoreProductBehavior;
use think\Url;
use app\routine\model\store\StoreCouponUser;
use app\routine\model\store\StoreOrder;
@ -54,14 +53,6 @@ use app\routine\model\article\Article as ArticleModel;
* Class AuthApi
* @package app\routine\controller
*
*
*
*
* https://qipei.9gt.net/routine/auth_api/index 首页
* https://qipei.9gt.net/routine/auth_api/store 分类页面
* https://qipei.9gt.net/routine/auth_api/get_pid_cate 一级分类
* https://qipei.9gt.net/routine/auth_api/get_id_cate 二级分类
* https://qipei.9gt.net/routine/auth_api/get_product_list 分类页面产品
*/
class AuthApi extends AuthController{
@ -88,7 +79,8 @@ class AuthApi extends AuthController{
*/
public function get_user_extract_bank(){
$extractBank = SystemConfig::getValue('user_extract_bank')?:[];//提现银行
$extractBank = explode('=',$extractBank);
$extractBank = str_replace("\r\n","\n",$extractBank);//防止不兼容
$extractBank = explode("\n",$extractBank);
return JsonService::successful($extractBank);
}
/**
@ -99,14 +91,18 @@ class AuthApi extends AuthController{
$menus = GroupDataService::getData('routine_home_menus')?:[];//banner图
$lovely = GroupDataService::getData('routine_lovely')?:[];//猜你喜欢图
$best = StoreProduct::getBestProduct('id,image,store_name,cate_id,price,unit_name,sort',8);//精品推荐
$new = StoreProduct::getNewProduct('id,image,store_name,cate_id,price,unit_name,sort',3);//今日上新
$hot = StoreProduct::getHotProduct('id,image,store_name,cate_id,price,unit_name,sort',6);//猜你喜欢
$new = StoreProduct::getNewProduct('id,image,store_name,cate_id,price,unit_name,sort',3);//首发
$hot = StoreProduct::getHotProduct('id,image,store_name,cate_id,price,unit_name,sort',8);//热卖
$benefit = StoreProduct::getBenefitProduct('id,image,store_name,cate_id,price,ot_price,stock,unit_name,sort',3);//促销
$like = StoreProduct::getHotProduct('id,image,store_name,cate_id,price,unit_name,sort',6);//猜你喜欢
$data['banner'] = $banner;
$data['lovely'] = $lovely[0];
$data['menus'] = $menus;
$data['best'] = $best;
$data['new'] = $new;
$data['hot'] = $hot;
$data['benefit'] = $benefit;
$data['like'] = $like;
return JsonService::successful($data);
}
@ -738,14 +734,16 @@ class AuthApi extends AuthController{
$orderInfo = StoreOrder::where('order_id',$orderId)->find();
if(!$orderInfo || !isset($orderInfo['paid'])) exception('支付订单不存在!');
if($orderInfo['paid']) exception('支付已支付!');
//如果支付金额为0
if(bcsub((float)$orderInfo['pay_price'],0,2) <= 0){
//创建订单jspay支付
if(StoreOrder::jsPayPrice($orderId,$this->userInfo['uid'],$formId))
return JsonService::status('success','微信支付成功',$info);
else
return JsonService::status('pay_error',StoreOrder::getErrorInfo());
}else{
try{
$jsConfig = StoreOrder::jsPay($orderId);
$jsConfig = StoreOrder::jsPay($orderId);//创建订单jspay
}catch (\Exception $e){
return JsonService::status('pay_error',$e->getMessage(),$info);
}
@ -832,22 +830,23 @@ class AuthApi extends AuthController{
else
return JsonService::fail(StoreOrder::getErrorInfo());
}
//TODO 支付订单
/**
* 支付订单
* @param string $uni
* @return \think\response\Json
*/
public function pay_order($uni = '')
public function pay_order($uni = '',$paytype='weixin')
{
if(!$uni) return JsonService::fail('参数错误!');
$order= StoreOrder::getUserOrderDetail($this->userInfo['uid'],$uni);
if(!$order) return JsonService::fail('订单不存在!');
if($order['paid']) return JsonService::fail('该订单已支付!');
if($order['pink_id']) if(StorePink::isPinkStatus($order['pink_id'])) return JsonService::fail('该订单已失效!');
$order['pay_type'] = $paytype;//重新支付选择支付方式
if($order['pay_type'] == 'weixin'){
try{
$jsConfig = StoreOrder::jsPay($order);
$jsConfig = StoreOrder::jsPay($order);//订单列表发起支付
}catch (\Exception $e){
return JsonService::fail($e->getMessage());
}
@ -1342,7 +1341,8 @@ class AuthApi extends AuthController{
$arr = User::where('spread_uid',$this->userInfo['uid'])->column('uid');
$list = StoreOrder::getUserOrderCount(implode(',',$arr),$type);
$price = [];
if(!empty($list)) foreach ($list as $k=>$v) $price[]=$v['pay_price'];
// if(!empty($list)) foreach ($list as $k=>$v) $price[]=$v['pay_price'];
if(!empty($list)) foreach ($list as $k=>$v) $price[]=$v;
$cont = count($list);
$sum = array_sum($price);
return JsonService::successful(['cont'=>$cont,'sum'=>$sum]);
@ -1436,7 +1436,7 @@ class AuthApi extends AuthController{
$path = makePathToUrl('routine/code');
if($path == '')
return JsonService::fail('生成上传目录失败,请检查权限!');
$picname = $path.DS.$this->userInfo['uid'].'.jpg';
$picname = $path.'/'.$this->userInfo['uid'].'.jpg';
$domain = SystemConfigService::get('site_url').'/';
$domainTop = substr($domain,0,5);
if($domainTop != 'https') $domain = 'https:'.substr($domain,5,strlen($domain));
@ -1738,7 +1738,8 @@ class AuthApi extends AuthController{
*/
public function get_combination_list_banner(){
$lovely = GroupDataService::getData('routine_lovely')?:[];//banner图
return JsonService::successful($lovely[3]);
$pic = isset($lovely[3])?$lovely[3]:'';
return JsonService::successful($pic);
}
/**
@ -1965,8 +1966,8 @@ class AuthApi extends AuthController{
if(!$id) return JsonService::fail('参数错误');
$count = StoreProduct::validWhere()->count();
if(!$count) return JsonService::fail('参数错误');
$path = 'public'.DS.'uploads'.DS.'codepath'.DS.'product';
$codePath = $path.DS.$id.'_'.$this->userInfo['uid'].'.jpg';
$path = UPLOAD_PATH.'/codepath/product/';
$codePath = $path.$id.'_'.$this->userInfo['uid'].'.jpg';
$domain = SystemConfigService::get('site_url').'/';
if(!file_exists($codePath)){
if(!is_dir($path)) mkdir($path,0777,true);

View File

@ -136,7 +136,10 @@ class StoreBargainUserHelp extends ModelBasic
$coverPrice = StoreBargainUser::getBargainUserDiffPrice($bargainId,$bargainUserId);//用户可以砍掉的金额
$bargainUserTableId = StoreBargainUser::getBargainUserTableId($bargainId,$bargainUserId);
$alreadyPrice= StoreBargainUser::getBargainUserPrice($bargainUserTableId);//用户已经砍掉的价格
return bcmul(bcdiv($alreadyPrice,$coverPrice,2),100,0);
if($alreadyPrice)
return bcmul(bcdiv($alreadyPrice,$coverPrice,2),100,0);
else
return 100;
}
}

View File

@ -26,7 +26,7 @@ use service\HookService;
use service\RoutineService;
use service\SystemConfigService;
use service\WechatService;
use service\WechatTemplateService;
use service\RoutineTemplateService;
use think\Cache;
use think\Url;
use traits\ModelTrait;
@ -56,25 +56,35 @@ class StoreOrder extends ModelBasic
return json_decode($value,true);
}
/**获取订单组信息
* @param $cartInfo
* @return array
*/
public static function getOrderPriceGroup($cartInfo)
{
$storePostage = floatval(SystemConfigService::get('store_postage'))?:0;
$storeFreePostage = floatval(SystemConfigService::get('store_free_postage'))?:0;
$totalPrice = self::getOrderTotalPrice($cartInfo);
$costPrice = self::getOrderCostPrice($cartInfo);
$storePostage = floatval(SystemConfigService::get('store_postage'))?:0;//邮费基础价
$storeFreePostage = floatval(SystemConfigService::get('store_free_postage'))?:0;//满额包邮
$totalPrice = self::getOrderTotalPrice($cartInfo);//获取订单总金额
$costPrice = self::getOrderCostPrice($cartInfo);//获取订单成本价
//如果满额包邮等于0
if(!$storeFreePostage) {
$storePostage = 0;
}else{
foreach ($cartInfo as $cart){
if(!$cart['productInfo']['is_postage'])
if(!$cart['productInfo']['is_postage'])//若果产品不包邮
$storePostage = bcadd($storePostage,$cart['productInfo']['postage'],2);
}
if($storeFreePostage <= $totalPrice) $storePostage = 0;
if($storeFreePostage <= $totalPrice) $storePostage = 0;//如果总价大于等于满额包邮 邮费等于0
}
// $totalPrice = bcadd($totalPrice,$storePostage,2);
return compact('storePostage','storeFreePostage','totalPrice','costPrice');
}
/**获取订单总金额
* @param $cartInfo
* @return int|string
*/
public static function getOrderTotalPrice($cartInfo)
{
$totalPrice = 0;
@ -83,6 +93,11 @@ class StoreOrder extends ModelBasic
}
return $totalPrice;
}
/**获取订单成本价
* @param $cartInfo
* @return int|string
*/
public static function getOrderCostPrice($cartInfo)
{
$costPrice=0;
@ -164,6 +179,20 @@ class StoreOrder extends ModelBasic
Cache::clear('user_order_'.$uid.$key);
}
/**生成订单
* @param $uid
* @param $key
* @param $addressId
* @param $payType
* @param bool $useIntegral
* @param int $couponId
* @param string $mark
* @param int $combinationId
* @param int $pinkId
* @param int $seckill_id
* @param int $bargain_id
* @return bool|object
*/
public static function cacheKeyCreateOrder($uid,$key,$addressId,$payType,$useIntegral = false,$couponId = 0,$mark = '',$combinationId = 0,$pinkId = 0,$seckill_id=0,$bargain_id=0)
{
if(!array_key_exists($payType,self::$payType)) return self::setErrorInfo('选择支付方式有误!');
@ -296,7 +325,7 @@ class StoreOrder extends ModelBasic
$key = substr($orderId,16);
return 'wx'.$ymd.date('His').$key;
}
//TODO JS支付
public static function jsPay($orderId,$field = 'order_id')
{
if(is_string($orderId))
@ -309,20 +338,20 @@ class StoreOrder extends ModelBasic
$openid = WechatUser::getOpenId($orderInfo['uid']);
return RoutineService::payRoutine($openid,$orderInfo['order_id'],$orderInfo['pay_price'],'productr',SystemConfigService::get('site_name'));
}
//TODO 余额支付
public static function yuePay($order_id,$uid,$formId = '')
{
$orderInfo = self::where('uid',$uid)->where('order_id',$order_id)->where('is_del',0)->find();
if(!$orderInfo) return self::setErrorInfo('订单不存在!');
if($orderInfo['paid']) return self::setErrorInfo('该订单已支付!');
if($orderInfo['pay_type'] != 'yue') return self::setErrorInfo('该订单不能使用余额支付!');
// if($orderInfo['pay_type'] != 'yue') return self::setErrorInfo('该订单不能使用余额支付!');
$userInfo = User::getUserInfo($uid);
if($userInfo['now_money'] < $orderInfo['pay_price'])
return self::setErrorInfo('余额不足'.floatval($orderInfo['pay_price']));
self::beginTrans();
$res1 = false !== User::bcDec($uid,'now_money',$orderInfo['pay_price'],'uid');
$res2 = UserBill::expend('购买商品',$uid,'now_money','pay_product',$orderInfo['pay_price'],$orderInfo['id'],$userInfo['now_money'],'余额支付'.floatval($orderInfo['pay_price']).'元购买商品');
$res3 = self::paySuccess($order_id,$formId);
$res3 = self::paySuccess($order_id,'yue',$formId);//余额支付成功
try{
// HookService::listen('yue_pay_product',$userInfo,$orderInfo,false,PaymentBehavior::class);
}catch (\Exception $e){
@ -347,7 +376,7 @@ class StoreOrder extends ModelBasic
$userInfo = User::getUserInfo($uid);
self::beginTrans();
$res1 = UserBill::expend('购买商品',$uid,'now_money','pay_product',$orderInfo['pay_price'],$orderInfo['id'],$userInfo['now_money'],'微信支付'.floatval($orderInfo['pay_price']).'元购买商品');
$res2 = self::paySuccess($order_id,$formId);
$res2 = self::paySuccess($order_id,'weixin',$formId);//微信支付为0时
$res = $res1 && $res2;
self::checkTrans($res);
return $res;
@ -394,14 +423,15 @@ class StoreOrder extends ModelBasic
/**
* //TODO 支付成功后
* @param $orderId
* @param $paytype
* @param $notify
* @return bool
*/
public static function paySuccess($orderId,$formId = '')
public static function paySuccess($orderId,$paytype='weixin',$formId = '')
{
$order = self::where('order_id',$orderId)->find();
$resPink = true;
$res1 = self::where('order_id',$orderId)->update(['paid'=>1,'pay_time'=>time()]);
$res1 = self::where('order_id',$orderId)->update(['paid'=>1,'pay_type'=>$paytype,'pay_time'=>time()]);//订单改为支付
User::bcInc($order['uid'],'pay_count',1,'uid');
if($order->combination_id && $res1 && !$order->refund_status) $resPink = StorePink::createPink($order);//创建拼团
$oid = self::where('order_id',$orderId)->value('id');
@ -414,20 +444,20 @@ class StoreOrder extends ModelBasic
public static function createOrderTemplate($order)
{
$goodsName = StoreOrderCartInfo::getProductNameList($order['id']);
WechatTemplateService::sendTemplate(WechatUser::getOpenId($order['uid']),WechatTemplateService::ORDER_CREATE, [
RoutineTemplateService::sendTemplate(WechatUser::getOpenId($order['uid']),RoutineTemplateService::ORDER_CREATE, [
'first'=>'亲,您购买的商品已支付成功',
'keyword1'=>date('Y/m/d H:i',$order['add_time']),
'keyword2'=>implode(',',$goodsName),
'keyword3'=>$order['order_id'],
'remark'=>'点击查看订单详情'
],Url::build('/wap/My/order',['uni'=>$order['order_id']],true,true));
WechatTemplateService::sendAdminNoticeTemplate([
'first'=>"亲,您有一个新订单 \n订单号:{$order['order_id']}",
'keyword1'=>'新订单',
'keyword2'=>'线下支付',
'keyword3'=>date('Y/m/d H:i',time()),
'remark'=>'请及时处理'
]);
// RoutineTemplateService::sendAdminNoticeTemplate([
// 'first'=>"亲,您有一个新订单 \n订单号:{$order['order_id']}",
// 'keyword1'=>'新订单',
// 'keyword2'=>'线下支付',
// 'keyword3'=>date('Y/m/d H:i',time()),
// 'remark'=>'请及时处理'
// ]);
}
public static function getUserOrderDetail($uid,$key)
@ -459,7 +489,7 @@ class StoreOrder extends ModelBasic
'keyword4'=>$postageData['delivery_name'],
'keyword5'=>$postageData['delivery_id']
]);
WechatTemplateService::sendTemplate($openid,WechatTemplateService::ORDER_DELIVER_SUCCESS,$group,$url);
RoutineTemplateService::sendTemplate($openid,RoutineTemplateService::ORDER_DELIVER_SUCCESS,$group,$url);
}else if($postageData['delivery_type'] == 'express'){//发货
$group = array_merge($group,[
@ -467,21 +497,21 @@ class StoreOrder extends ModelBasic
'keyword2'=>$postageData['delivery_name'],
'keyword3'=>$postageData['delivery_id']
]);
WechatTemplateService::sendTemplate($openid,WechatTemplateService::ORDER_POSTAGE_SUCCESS,$group,$url);
RoutineTemplateService::sendTemplate($openid,RoutineTemplateService::ORDER_POSTAGE_SUCCESS,$group,$url);
}
}
public static function orderTakeAfter($order)
{
$openid = WechatUser::getOpenId($order['uid']);
WechatTemplateService::sendTemplate($openid,WechatTemplateService::ORDER_TAKE_SUCCESS,[
'first'=>'亲,您的订单以成功签收,快去评价一下吧',
'keyword1'=>$order['order_id'],
'keyword2'=>'已收货',
'keyword3'=>date('Y/m/d H:i',time()),
'keyword4'=>implode(',',StoreOrderCartInfo::getProductNameList($order['id'])),
'remark'=>'点击查看订单详情'
],Url::build('My/order',['uni'=>$order['order_id']],true,true));
// $openid = WechatUser::getOpenId($order['uid']);
// RoutineTemplateService::sendTemplate($openid,RoutineTemplateService::ORDER_TAKE_SUCCESS,[
// 'first'=>'亲,您的订单已成功签收,快去评价一下吧',
// 'keyword1'=>$order['order_id'],
// 'keyword2'=>'已收货',
// 'keyword3'=>date('Y/m/d H:i',time()),
// 'keyword4'=>implode(',',StoreOrderCartInfo::getProductNameList($order['id'])),
// 'remark'=>'点击查看订单详情'
// ],Url::build('My/order',['uni'=>$order['order_id']],true,true));
}
/**

View File

@ -46,6 +46,7 @@ class StoreProduct extends ModelBasic
return $model->select();
}
/**
* 热卖产品
* @param string $field

View File

@ -7,7 +7,7 @@
namespace app\routine\model\store;
use behavior\wap\StoreProductBehavior;
use behavior\routine\StoreProductBehavior;
use service\HookService;
use traits\ModelTrait;
use basic\ModelBasic;

View File

@ -17,8 +17,10 @@ Page({
duration: 500,//动画播放的时长;
indicatorColor: "rgba(51, 51, 51, .3)",
indicatorActivecolor: "#ffffff",
recommendLsit:[],
recommendList:[],
newList:[],
hotList:[],
benefitList:[],
likeList:[],
offset: 0,
title: "玩命加载中...",
@ -60,11 +62,13 @@ Page({
success: function (res) {
that.setData({
imgUrls: res.data.data.banner,
recommendLsit: res.data.data.best,
newList: res.data.data.new,
lovely: res.data.data.lovely,
menus: res.data.data.menus,
likeList: res.data.data.hot
recommendList: res.data.data.best,//精品
newList: res.data.data.new,//首发新品
hotList: res.data.data.hot,//热卖单品
benefitList: res.data.data.benefit,//促销
lovely: res.data.data.lovely,//猜猜你喜欢上面广告位
menus: res.data.data.menus,//导航
likeList: res.data.data.like//猜猜喜欢
})
}
})

View File

@ -32,7 +32,7 @@
</view>
<view class='scroll-product'>
<scroll-view class="scroll-view_x" scroll-x style="width: auto;overflow:hidden;">
<block wx:for="{{recommendLsit}}">
<block wx:for="{{recommendList}}">
<view class='item'>
<navigator hover-class="none" url="/pages/product-con/index?id={{item.id}}">
<view class='img-box'><image src='{{url}}{{item.image}}'></image></view>
@ -46,11 +46,11 @@
</scroll-view>
</view>
</view>
<!-- 今日上新 -->
<!-- 首发新品 -->
<view class='today-new'>
<view class='title-bar' bindtap='torday'>
<view class='iconfont icon-shangxinfuwu'></view>
<text>今日上新</text>
<text>首发新品</text>
<navigator hover-class="none" bindtap='torday' class='flex'><text>更多新品</text><text class='iconfont icon-xiala'></text></navigator>
</view>
<view class='new-pro-wrapper'>
@ -67,6 +67,54 @@
</block>
</view>
</view>
<!-- 热卖单品 -->
<view class='new-product2'>
<view class='title-bar' bindtap='torday' >
<view class='iconfont icon-jingpintuijian'></view>
<text>热卖单品</text>
<navigator hover-class="none" class='flex'><text>更多推荐</text><text class='iconfont icon-xiala'></text></navigator>
</view>
<view class='scroll-product2'>
<scroll-view class="scroll-view_x" scroll-x style="width: auto;overflow:hidden;">
<block wx:for="{{hotList}}">
<view class='item'>
<navigator hover-class="none" url="/pages/product-con/index?id={{item.id}}">
<view class='img-box'><image src='{{url}}{{item.image}}'></image></view>
<view class='pro-info'>
<view class='pro-title'>{{item.store_name}}</view>
<view class='price-small'>¥{{item.price}}</view>
<view class='buy flex'><image src="/images/carts.png"></image>立即购买</view>
</view>
</navigator>
</view>
</block>
</scroll-view>
</view>
</view>
<view class='today-new'>
<view class='title-bar' bindtap='torday'>
<view class='iconfont icon-shangxinfuwu'></view>
<text>促销单品</text>
<navigator hover-class="none" bindtap='torday' class='flex'><text>更多新品</text><text class='iconfont icon-xiala'></text></navigator>
</view>
<view class='new-pro-wrapper2'>
<block wx:for="{{benefitList}}">
<view class='item'>
<navigator class='flex' hover-class="none" url="/pages/product-con/index?id={{item.id}}">
<view class='text-box flex'>
<view class='title'>{{item.store_name}}</view>
<view class='salePrice'>促销价: ¥<text>{{item.price}}</text></view>
<view class='price flex'>
<view class='dailyPrice'>日常价:{{item.ot_price}}</view>
<view>仅剩:{{item.stock}}</view>
</view>
</view>
<view class='img-box'><image src='{{url}}{{item.image}}'></image></view>
</navigator>
</view>
</block>
</view>
</view>
<block wx:for="{{lovely}}" wx:if="{{index < 1}}">
<view class='hot-banner'>
<image src='{{url}}{{item.img}}'></image>

View File

@ -42,3 +42,26 @@
.product-like .like-box .item .text-info .title{overflow: hidden;white-space: nowrap;text-overflow: ellipsis;}
.product-like .like-box .item .text-info .price{color:#ff3d3d;}
.new-product2{margin-top: 30rpx; background-color: #fff;}
.scroll-product2{width: 100%; overflow: hidden; white-space: nowrap; padding:25rpx 0 35rpx 30rpx; box-sizing: border-box;}
.scroll-product2 .item{width: 304rpx;margin-right: 28rpx; display: inline-block;border:1rpx solid #eee;border-radius:20rpx;}
.scroll-product2 .item .img-box{width: 100%; height: 304rpx;}
.scroll-product2 .item .img-box image{width: 100%; height: 304rpx;border-radius:20rpx 20rpx 0 0;}
.scroll-product2 .item .pro-info .price-small{color: #ff3d3d;font-size:26rpx;
margin-top:10rpx;text-align:center;}
.scroll-product2 .item .pro-info .pro-title{text-align:center;margin-top:25rpx;}
.scroll-product2 .item .pro-info .buy{width:250rpx;height:54rpx;background-color:#e6413a;border-radius:50rpx;font-size:24rpx;color:#fff;align-items:center;justify-content:center;margin:17rpx auto 25rpx auto;}
.scroll-product2 .item .pro-info .buy image{width:27rpx;height:26rpx;margin-right:12rpx;}
.new-pro-wrapper2{padding: 0 30rpx;}
.new-pro-wrapper2 .item navigator{width: 100%; padding:36rpx 0; border-bottom: 1px solid #eee; justify-content: space-between; box-sizing: border-box;flex-direction:row-reverse;}
.new-pro-wrapper2 .item .text-box{width:470rpx; flex-direction: column; justify-content: space-around;}
.new-pro-wrapper2 .item .text-box .salePrice{width:210rpx;height:46rpx;text-align:center;line-height:46rpx;font-size:20rpx;color:#fff;background-image:linear-gradient(to right,#ff6248 0%,#ff3e1e 100%);border-radius:30rpx 0 30rpx 0rpx;margin-top:18rpx;}
.new-pro-wrapper2 .item .text-box .salePrice text{font-size:24rpx;}
.new-pro-wrapper2 .item .text-box .title{display: -webkit-box; display:-moz-box; display:box;-webkit-box-orient: vertical; -moz-box-orient: vertical; -webkit-line-clamp: 1;-moz-line-clamp: 1;overflow: hidden;}
.new-pro-wrapper2 .item .text-box .price{color: #999; font-size:24rpx;justify-content:space-between;align-items:center;}
.new-pro-wrapper2 .item .text-box .price .dailyPrice{text-decoration:line-through;}
.new-pro-wrapper2 .item .text-box .price text{font-size: 28rpx;}
.new-pro-wrapper2 .item .img-box image{width:188rpx; height:188rpx;border-radius:10rpx;}

View File

@ -15,6 +15,7 @@ Page({
cartInfo : [],
cartId : '',
priceGroup :[],
totalPrice:0,
orderKey:'',
seckillId:0,
BargainId:0,
@ -27,7 +28,7 @@ Page({
url: app.globalData.urlImages,
addressId:0,
couponId:0,
couponPrice:'',
couponPrice:0,
couponInfo:[],
addressInfo:[],
mark:'',
@ -70,6 +71,7 @@ Page({
}
that.getaddressInfo();
that.getCouponRope();
},
bindHideKeyboard:function(e){
this.setData({
@ -183,7 +185,7 @@ Page({
},
fail: function(res) {
wx.showToast({
title: '支付失败',
title: '支付取消',
icon: 'none',
duration: 1000,
})
@ -232,7 +234,8 @@ Page({
if (res.data.code == 200) {
that.setData({
couponInfo: res.data.data,
couponPrice: '-' + res.data.data.coupon_price
// couponPrice: '-' + res.data.data.coupon_price,
totalPrice: Number(that.data.totalPrice) - Number(res.data.data.coupon_price)
})
}else{
that.setData({
@ -263,7 +266,7 @@ Page({
})
}else{
wx.request({
url: app.globalData.url + '/routine/auth_api/user_default_address?uid=' + app.globalData.uid,
url: app.globalData.url + '/routine/auth_api/user_default_address?uid=' + app.globalData.uid+ '&openid=' + app.globalData.openid,
method: 'GET',
success: function (res) {
if (res.data.code == 200) {
@ -282,7 +285,7 @@ Page({
'content-type': 'application/x-www-form-urlencoded'
};
wx.request({
url: app.globalData.url + '/routine/auth_api/user_address_list?uid=' + app.globalData.uid,
url: app.globalData.url + '/routine/auth_api/user_address_list?uid=' + app.globalData.uid + '&openid=' + app.globalData.openid,
method: 'POST',
header: header,
success: function (res) {
@ -332,6 +335,7 @@ Page({
offlinePostage: res.data.data.offlinePostage,
orderKey: res.data.data.orderKey,
priceGroup: res.data.data.priceGroup,
totalPrice: Number(res.data.data.priceGroup.totalPrice) + Number(res.data.data.priceGroup.storePostage),
cartId: res.data.data.cartId,
seckillId: res.data.data.seckill_id,
usableCoupon: res.data.data.usableCoupon

View File

@ -47,12 +47,14 @@
<view class='warapper'>
<view class='item '>
<radio-group >
<label class='radio-wrapper' wx:for="{{cartArr}}">
<view class='left-wrapper flex'><view class='iconfont {{item.icon}}'></view> {{item.name}}</view>
<radio value="{{index}}" wx:if="{{item.value == payType}}" checked='checked' bindtap="radioChange" data-value="{{item.value}}"></radio>
<radio value="{{index}}" wx:else bindtap="radioChange" data-value="{{item.value}}"></radio>
<!-- 其他布局代码 -->
</label>
<label class='radio-wrapper' wx:for="{{cartArr}}" bindtap="radioChange" data-value="{{item.value}}">
<view class='left-wrapper flex'>
<view class='iconfont {{item.icon}}'></view> {{item.name}}
</view>
<radio value="{{index}}" wx:if="{{item.value == payType}}" checked='checked' ></radio>
<radio value="{{index}}" wx:else></radio>
<!-- 其他布局代码 -->
</label>
</radio-group>
<!-- <view class='left-wrapper'>微信支付</view>
<view class='right-wrapper flex'>
@ -72,7 +74,7 @@
<view style='height:120rpx;'></view>
<view class='foot flex'>
<view class='text'>
合计: <text class='price'>¥{{priceGroup.totalPrice}}{{couponPrice}}</text>
合计: <text class='price'>¥{{totalPrice}}</text>
</view>
<form bindsubmit="subOrder" report-submit='true'>
<button class='submit-btn' formType="submit">立即结算</button>

View File

@ -31,7 +31,7 @@ Page({
success: function (res) {
wx.hideLoading();
that.setData({
ordercon:res.data.data
ordercon: res.data.data
});
},
fail: function (res) {
@ -42,10 +42,114 @@ Page({
}
});
},
getPay:function(e){
//选择付款方式
checkPay: function (e) {
var that = this;
wx.showActionSheet({
itemList: ['微信支付', '余额支付'],
success(res) {
console.log(res.tapIndex)
if (res.tapIndex == 0) {//微信支付
wx.request({
url: app.globalData.url + '/routine/auth_api/pay_order?uid=' + app.globalData.uid + '&uni=' + e.target.dataset.id + '&paytype=weixin',
method: 'get',
success: function (res) {
var data = res.data.data;
if (res.data.code == 200) {
var jsConfig = res.data.data.result.jsConfig;
console.log(jsConfig);
wx.requestPayment({
timeStamp: jsConfig.timeStamp,
nonceStr: jsConfig.nonceStr,
package: jsConfig.package,
signType: jsConfig.signType,
paySign: jsConfig.paySign,
success: function (res) {
wx.showToast({
title: '支付成功',
icon: 'success',
duration: 1000,
})
setTimeout(function () {
wx.navigateTo({ //跳转至指定页面并关闭其他打开的所有页面
url: '/pages/orders-list/orders-list?uid=' + app.globalData.uid
// url: '/pages/orders-con/orders-con?order_id=' + data.result.order_id
})
}, 1200)
},
fail: function (res) {
wx.showToast({
title: '取消支付',
icon: 'success',
duration: 1000,
})
},
complete: function (res) {
console.log(res);
if (res.errMsg == 'requestPayment:cancel') {
wx.showToast({
title: '取消支付',
icon: 'none',
duration: 1000,
})
}
},
})
}
},
fail: function (res) {
console.log('submit fail');
}
});
} else {
wx.request({
url: app.globalData.url + '/routine/auth_api/pay_order?uid=' + app.globalData.uid + '&uni=' + e.target.dataset.id + '&paytype=yue',
method: 'get',
success: function (res) {
var data = res.data.data;
if (res.data.code == 200) {
wx.showToast({
title: res.data.msg,
icon: 'success',
duration: 2000
})
setTimeout(function () {
wx.navigateTo({ //跳转至指定页面并关闭其他打开的所有页面(这个最好用在返回至首页的的时候)
url: '/pages/orders-list/orders-list?uid=' + app.globalData.uid
// url: '/pages/orders-con/orders-con?order_id=' + data.result.orderId
})
}, 1200)
} else {
wx.showToast({
title: res.data.msg,
icon: 'none',
duration: 2000
})
}
},
fail: function (res) {
console.log('submit fail');
}
});
}
},
fail(res) {
console.log(res.errMsg)
},
// complete(res) {
// setTimeout(function () {
// wx.navigateTo({
// url: '/pages/orders-list/orders-list',
// })
// }, 1500)
// },
})
},
//立即付款
getPay: function (e) {
var that = this;
wx.request({
url: app.globalData.url + '/routine/auth_api/pay_order?uid=' + app.globalData.uid +'&uni='+e.target.dataset.id,
url: app.globalData.url + '/routine/auth_api/pay_order?uid=' + app.globalData.uid + '&uni=' + e.target.dataset.id,
method: 'get',
success: function (res) {
var data = res.data.data;
@ -66,7 +170,7 @@ Page({
})
setTimeout(function () {
wx.navigateTo({ //跳转至指定页面并关闭其他打开的所有页面(这个最好用在返回至首页的的时候)
url: '/pages/orders-con/orders-con?order_id=' + data.result.order_id
url: '/pages/orders-list/orders-list?uid=' + app.globalData.uid
})
}, 1200)
},
@ -76,11 +180,11 @@ Page({
icon: 'success',
duration: 1000,
})
// setTimeout(function () {
// wx.navigateTo({
// url: '/pages/orders-con/orders-con?order_id=' + data.result.orderId
// })
// }, 1200)
setTimeout(function () {
wx.navigateTo({
url: '/pages/orders-list/orders-list?uid=' + app.globalData.uid
})
}, 1200)
},
complete: function (res) {
console.log(res);
@ -90,15 +194,15 @@ Page({
icon: 'none',
duration: 1000,
})
// setTimeout(function () {
// wx.navigateTo({ //跳转至指定页面并关闭其他打开的所有页面(这个最好用在返回至首页的的时候)
// url: '/pages/orders-con/orders-con?order_id=' + data.result.orderId
// })
// }, 1200)
setTimeout(function () {
wx.navigateTo({ //跳转至指定页面并关闭其他打开的所有页面(这个最好用在返回至首页的的时候)
url: '/pages/orders-list/orders-list?uid=' + app.globalData.uid
})
}, 1200)
}
},
})
} else if (res.data.code == 200){
} else if (res.data.code == 200) {
wx.showToast({
title: res.data.msg,
icon: 'success',
@ -109,7 +213,7 @@ Page({
url: '/pages/orders-con/orders-con?order_id=' + data.result.orderId
})
}, 1200)
}else{
} else {
wx.showToast({
title: res.data.msg,
icon: 'none',
@ -127,7 +231,7 @@ Page({
}
});
},
delOrder:function(e){
delOrder: function (e) {
var header = {
'content-type': 'application/x-www-form-urlencoded'
};
@ -150,11 +254,11 @@ Page({
icon: 'success',
duration: 2000
})
setTimeout(function(){
setTimeout(function () {
wx.navigateTo({
url: '/pages/orders-list/orders-list',
})
},1500)
}, 1500)
} else {
wx.showToast({
title: res.data.msg,
@ -179,19 +283,19 @@ Page({
}
})
},
goTel:function(e){
goTel: function (e) {
console.log(e);
wx.makePhoneCall({
phoneNumber: e.currentTarget.dataset.tel //仅为示例,并非真实的电话号码
})
},
goJoinPink:function(e){
goJoinPink: function (e) {
var uni = e.currentTarget.dataset.uni;
wx.navigateTo({
url: '/pages/join-pink/index?id=' + uni,
})
},
confirmOrder:function(e){
confirmOrder: function (e) {
var header = {
'content-type': 'application/x-www-form-urlencoded'
};
@ -208,11 +312,11 @@ Page({
method: 'get',
header: header,
success: function (res) {
if(res.data.code==200){
if (res.data.code == 200) {
wx.navigateTo({
url: '/pages/orders-list/orders-list?nowstatus=4',
})
}else{
} else {
wx.showToast({
title: res.data.msg,
icon: 'none',
@ -236,57 +340,57 @@ Page({
}
})
},
goIndex:function(){
wx.switchTab({
url: '/pages/index/index'
})
goIndex: function () {
wx.switchTab({
url: '/pages/index/index'
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

View File

@ -111,11 +111,12 @@
</view>
<view style='height:120rpx;'></view>
<view class='foot'>
<view class='pay-btn' data-id="{{ordercon.order_id}}" bindtap='getPay' wx:if="{{ordercon._status._type==0}}">立即付款</view>
<view class='pay-btn' data-id="{{ordercon.order_id}}" bindtap='checkPay' wx:if="{{ordercon._status._type==0}}">立即付款</view>
<navigator wx:elif="{{ordercon._status._type==1}}" hover-class="none" url='/pages/refund-page/refund-page?orderId={{ordercon.order_id}}'><view class='delete-btn'>申请退款</view></navigator>
<view wx:if="{{ordercon._status._type==1 && ordercon.combination_id > 0}}" class='pay-btn' bindtap='goJoinPink' data-uni='{{ordercon.pink_id}}'>查看拼团</view>
<navigator wx:if="{{ordercon._status._type==2 && ordercon.delivery_type == 'express'}}" hover-class="none" url='/pages/logistics/logistics?orderId={{ordercon.order_id}}'><view class='delete-btn' >查看物流</view></navigator>
<view wx:if="{{ordercon._status._type==2}}" class='pay-btn' bindtap='confirmOrder' data-uni='{{ordercon.order_id}}'>确认收货</view>
<view wx:if="{{ordercon._status._type==4 || ordercon._status._type==0}}" class='delete-btn' bindtap='delOrder' data-uni='{{ordercon.order_id}}'>删除订单</view>
<navigator wx:if="{{!ordercon.seckill_id && !ordercon.bargain_id && !ordercon.combination_id && (ordercon._status._type==3||ordercon._status._type==4)}}" hover-class="none" bindtap='goIndex'><view class='pay-btn'>再次购买</view></navigator>
</view>
</view>
<include src="/pages/home/home.wxml"/>

View File

@ -42,5 +42,6 @@
.foot view{width: 160rpx; height: 58rpx; line-height: 56rpx; text-align: center; box-sizing: border-box; border: 1px solid #999; color: #aaa; border-radius: 30px; font-size: 24rpx;}
.foot view.pay-btn{background-color: #ff3d3d;border: 0; color: #fff;}
.delete-btn{margin-right: 20rpx;display:block;}
@import "/pages/home/home.wxss";

View File

@ -71,7 +71,7 @@ Page({
duration: 1000,
})
that.setData({
now_money: parseInt(that.data.now_money) + parseInt(e.detail.value.number)
now_money: parseFloat(that.data.now_money) + parseFloat(e.detail.value.number)
});
setTimeout(function () {
wx.navigateTo({

View File

@ -5,7 +5,7 @@
<view class='refunding-ul'>
<view class='refunding-li flex'>
<view>退款总金额</view>
<view class='li-money'>¥<text>{{ordercon.refund_price}}</text></view>
<view class='li-money'>¥<text>{{ordercon.pay_price}}</text></view>
</view>
<view class='refunding-li flex'>
<view>退回微信账户</view>