Commit 465e9148 authored by IvyXia123's avatar IvyXia123

20191009-打卡

parent ae07b3e9
<template>
<div class="group-buy">
<!-- <guidelines v-if="guidelinesShow"></guidelines>-->
<div :style="{backgroundImage:`url('${lineImage}')`}" class="main-background">
<div class="title-top">
<img :src="clock" />
......@@ -74,7 +71,7 @@
</div>
<!-- 支付方式选择 -->
<div class="pay-list">
<!--<div class="pay-list">
<div class="pay-choice">支付方式选择</div>
<ul class="pay">
<li v-for="item in payList" :key="item.value" @click="payListClick(item.value)">
......@@ -85,8 +82,7 @@
</div>
</li>
</ul>
</div>
</div>-->
<footer>
<div class="sub-block">
......@@ -95,8 +91,11 @@
class="tips-price"
v-if="groupDetail.goods_desc"
>{{groupDetail.goods_desc.tips?groupDetail.goods_desc.tips:''}}</span>
<!-- <div class="pay-btn" @click="payOrder(orderFlag)">提交订单</div>-->
<div class="pay-btn" @click="payOrder(orderFlag)">提交订单</div>
<!--<div class="pay-btn" @click="payOrder(orderFlag)"
v-clipboard:copy="payIndex !== 0 ? payUrl : ''"
v-clipboard:success="copy"
v-clipboard:error="onError">提交订单</div>-->
</div>
</footer>
<transition name="slide-fade">
......@@ -131,8 +130,8 @@
</template>
<script>
import { Toast } from "vant";
import {
import { Toast } from "vant";
import {
getUserAdressApi,
getGoodsDetailApi,
payApi,
......@@ -141,33 +140,31 @@
getCouponListApi,
getCourseInfoApi,
postPayBillApi
} from "../../service/api";
import addAddress from "./address";
import loginPage from "./login";
import youHuiUrl from "../../assets/shop/pic.png";
import saleDiv from "./sale";
import lineImage from "../../assets/shop/buyBg.png";
import clock from "../../assets/shop/clock.png";
import addressImg from "../../assets/shop/address.png";
import leftG from "../../assets/shop/leftg.png";
import popup_img from "../../assets/shop/popup_img@2x.png";
import weixin from "../../assets/evaluate/weixin.png";
import zhifubao from "../../assets/evaluate/zhifubao.png";
import xinyongka from "../../assets/evaluate/xinyongka.png";
import fenqi from "../../assets/evaluate/fenqi.png";
import icon_re from "../../assets/evaluate/icon_re.png";
import icon_re_acitve from "../../assets/evaluate/icon_re_acitve.png";
import { Popup } from "mint-ui";
import guidelines from './guidelines'
} from "../../service/api";
import addAddress from "./address";
import loginPage from "./login";
import youHuiUrl from "../../assets/shop/pic.png";
import saleDiv from "./sale";
import lineImage from "../../assets/shop/buyBg.png";
import clock from "../../assets/shop/clock.png";
import addressImg from "../../assets/shop/address.png";
import leftG from "../../assets/shop/leftg.png";
import popup_img from "../../assets/shop/popup_img@2x.png";
import weixin from "../../assets/evaluate/weixin.png";
import zhifubao from "../../assets/evaluate/zhifubao.png";
import xinyongka from "../../assets/evaluate/xinyongka.png";
import fenqi from "../../assets/evaluate/fenqi.png";
import icon_re from "../../assets/evaluate/icon_re.png";
import icon_re_acitve from "../../assets/evaluate/icon_re_acitve.png";
import { Popup } from "mint-ui";
export default {
export default {
name: "buy",
components: {
addAddress,
saleDiv,
loginPage,
[Popup.name]: Popup,
guidelines
[Popup.name]: Popup
},
data() {
return {
......@@ -213,9 +210,12 @@
userCourse: {},
payList: [
{ icon: weixin, title: '微信支付', value: 0 },
{ icon: zhifubao, title: '支付宝支付', value: 1 }
{ icon: zhifubao, title: '支付宝支付', value: 1 },
{ icon: xinyongka,title: '信用卡分期', value: 2 },
{ icon: fenqi, title: '其他分期', value: 3 },
],
payIndex: 0,
payUrl: ''
};
},
mounted() {
......@@ -247,9 +247,20 @@
}
},
methods: {
copy(e) {
if(this.payIndex === 1) {
Toast("支付宝支付获取成功,请把粘贴到支付宝里");
}else if(this.payIndex === 2) {
Toast("信用卡支付获取成功");
}
},
onError() {
if(this.payIndex === 1) {
Toast("信用卡支付获取成功");
}
},
// 支付方式
payListClick(val) {
this.orderFlag = true;
this.payIndex = val
},
recursion() {
......@@ -272,10 +283,13 @@
that.jsApiParameters,
function(res) {
that.orderFlag = true;
console.log(res,110);
if (res.err_msg === "get_brand_wcpay_request:ok") {
// 支付成功后处理
console.log(237)
Toast("支付成功");
setTimeout(() => {
console.log(238)
getCourseInfoApi().then(res => {
that.userCourse = JSON.parse(JSON.stringify(res));
localStorage.setItem(
......@@ -286,6 +300,8 @@
});
}, 1500);
}
// alert(res.errMsg)
// alert(res.err_msg)
if (res.err_msg === "get_brand_wcpay_request:fail") {
}
if (res.err_msg === "get_brand_wcpay_request:cancel") {
......@@ -303,10 +319,10 @@
},
buttonClick(buttonType, buttonName) {
this.$sa.track("buttonClick", {
tabTitle : "商品",
moduleTitle : "购买页",
buttonType : buttonType,
buttonName : buttonName
tabTitle: "商品",
moduleTitle: "购买页",
buttonType: buttonType,
buttonName: buttonName
});
},
goToBuyPage() {
......@@ -314,7 +330,6 @@
this.bindMobile.show = false;
},
payOrder(flag) {
console.log(flag)
let type = this.type ? 0 : 1;
let that = this;
this.orderCancel = false;
......@@ -365,8 +380,18 @@
}
this.orderFlag = false;
/*let payTypeArr = ['WX', 'ALI', 'KFQ']
let data = { pay_type: payTypeArr[this.payIndex], return_url: window.location.href, goods_id: json.goods_id, buy_type: this.groupDetail.goods_type, group_order_id: json.group_order_id, order_coupon_id:json.order_coupon_id }
postPayBillApi(data).then(res => {
if(this.payIndex === 0) {
// 微信支付
window.location.href = res.pay_url;
}else if(this.payIndex === 1){
this.payUrl = res.pay_url;
}else if(this.payIndex === 2) {
this.payUrl = res.pay_url;
}
})*/
payApi(json).then(res => {
this.orderNo = res.out_trade_no;
console.log(res)
......@@ -413,20 +438,6 @@
// alert(res)
this.orderFlag = true;
});
}else {
// 支付宝支付
let data = { pay_type: 'ALI', return_url: window.location.href, buy_type: this.groupDetail.goods_type }
let dataObj = Object.assign({}, data, json)
postPayBillApi(dataObj).then(res => {
let outTradEno = JSON.stringify({ out_trade_no: res.out_trade_no, invite_code: this.$route.query.invite_code, shopId: this.$route.query.shopId, goods_type: this.groupDetail.goods_type, is_subscribe: this.userDetail.open_info.is_subscribe })
localStorage.setItem('out_trade_no', outTradEno);
localStorage.setItem('pay_url', res.pay_url);
location.href = `http://${ window.location.host }/#/guidelines?pay_url=${ encodeURI(res.pay_url) }`
}).catch(err => {
console.log(err)
Toast(err.msg)
})
}
}
},
closeAdd(data) {
......@@ -473,7 +484,7 @@
data.goods_desc = JSON.parse(data.goods_desc);
data.share_desc = JSON.parse(data.share_desc);
this.groupDetail = JSON.parse(JSON.stringify(data));
localStorage.setItem("groupDetail", JSON.stringify(data));
sessionStorage.setItem("groupDetail", JSON.stringify(data));
console.log(this.groupDetail, 408);
this.invite_code = this.$route.query.invite_code;
if (this.type && this.type === 0) {
......@@ -547,18 +558,18 @@
}
}
}
};
};
</script>
<style scoped lang="less">
@import "../../util/public";
img {
@import "../../util/public";
img {
max-width: none;
}
.slide-fade-enter-active {
}
.slide-fade-enter-active {
transition: all 0.5s ease;
}
.you-block {
}
.you-block {
font-size: 16 * @toVw;
font-family: PingFang-SC-Medium;
font-weight: 500;
......@@ -578,8 +589,8 @@
color: #999999;
font-size: 14 * @toVw;
}
}
.orderCancel {
}
.orderCancel {
top: 45%;
background: transparent;
.box {
......@@ -630,22 +641,22 @@
}
}
}
}
}
.slide-fade-leave-active {
.slide-fade-leave-active {
transition: all 0.5s cubic-bezier(1, 0.5, 0.8, 1);
}
.slide-fade-enter, .slide-fade-leave-to
}
.slide-fade-enter, .slide-fade-leave-to
/* .slide-fade-leave-active for below version 2.1.8 */ {
transform: translateX(10px);
opacity: 0;
}
.phone-block {
}
.phone-block {
padding: 10 * @toVw;
text-align: center;
background: #f8f8f8;
}
.phone-input {
}
.phone-input {
width: 280 * @toVw;
height: 30 * @toVw;
border-radius: 8 * @toVw;
......@@ -653,13 +664,13 @@
padding: 0 10 * @toVw;
border: 1px solid #e8e8e8;
text-align: center;
}
.block-title {
}
.block-title {
font-size: 12 * @toVw;
color: #999;
padding: 8 * @toVw 16 * @toVw;
}
.group-buy {
}
.group-buy {
.main-background {
padding: 0 20 * @toVw;
background: white no-repeat;
......@@ -879,5 +890,5 @@
position: absolute;
background: white;
}
}
}
</style>
<template>
<div class="guidelines">
<div class="zhiying" v-if="micromessenger == 0">
<img :src="zhiying" alt="">
</div>
</div>
</template>
<script>
import common from '../../util/common'
import zhiying from "../../assets/punchTheClock/zhiying.png"
import zhufubao from "../../assets/punchTheClock/zhifubaotup.png"
export default {
name: "guidelines",
data() {
return {
micromessenger: 0, // 判断在微信里还是在浏览器里
zhiying: zhiying, // 图片
zhufubao: zhufubao
}
},
mounted() {
// 0 -> 微信 1 -> 支付宝
this.micromessenger = common.isWeixinBrowser()
// 到浏览器里支付宝支付
if (this.micromessenger == 1) {
location.href = this.$route.query.pay_url
}
}
}
</script>
<style scoped lang="less">
@import "../../util/public";
.guidelines {
width: 100%;
height: 100%;
padding-top: 3 * @toVw;
background: #F3F2F7;
text-align: center;
.zhiying {
width: 244 * @toVw;
height: 361 * @toVw;
margin-left: 112 * @toVw;
box-sizing: border-box;
img {
width: 100%;
height: 100%;
}
}
}
</style>
......@@ -11,7 +11,7 @@
<div class="punch-the-clock-name-bg">
<div class="punch-the-clock-name-content">
<!-- 倒计时 hasEnded 指是否在规定时间内完成学习 -->
<div class="punch-the-clock-name-contentText" v-if="!hasEnded && forthRate != 100">很遗憾,您未在指定时间内完成任务哦</div>
<div class="punch-the-clock-name-contentText" v-if="!hasEnded">很遗憾,您未在指定时间内完成任务哦</div>
<div class="punch-the-clock-name-content-timer" v-if="hasEnded">
<span>剩余完成时间</span>
<span class="timer">{{ countDownDay }}</span>
......
......@@ -10,12 +10,10 @@ import VueClipboard from 'vue-clipboard2'
import sa from 'sa-sdk-javascript';
import 'mint-ui/lib/style.css'
import scroll from "./base/scroll/scroll"
import {Popup, Lazyload, Button, Dialog, Toast} from 'vant';
import {getBillRefreshApi, getStatusWechatApi,getCourseInfoApi} from './service/api'
import './util/vancs.less'
import { Popup, Lazyload, Button, Dialog, Toast } from 'vant';
import * as fundebug from 'fundebug-javascript';
import fundebugVue from 'fundebug-vue';
fundebug.apikey = '4d414770c72b034dfa896048206a72258ede4e4ad5f9c6c4320d19b7f91a567e';
fundebugVue(fundebug, Vue);
......@@ -48,62 +46,12 @@ Vue.prototype.$sa.quick('autoTrack')
Vue.use(VueClipboard);
Vue.use(Popup).use(Lazyload).use(Button).use(Dialog).use(Toast);
Vue.component('scroll', scroll);
// 支付宝支付完成,订单状态查询
let timer = null;
if (window.localStorage.out_trade_no) {
timer = setInterval(() => {
let outTradEno = JSON.parse(window.localStorage.out_trade_no);
getBillRefreshApi({outTradeNo: outTradEno.out_trade_no}).then(res => {
// 支付成功
if (res.status === "SUCCESS") {
getCourseInfoApi().then(response => {
this.userCourse = JSON.parse(JSON.stringify(response));
console.log(this.userCourse)
localStorage.setItem("userCourse", JSON.stringify(this.userCourse));
localStorage.setItem("buyindex", 1);
Dialog.confirm({title: '标题', message: '支付成功', confirmButtonText: '去查看'}).then(() => {
if (response.teacher_alias && response.teacher_alias.substr(0, 1) == 1 && outTradEno.goods_type != 4 && outTradEno.is_subscribe == 1) {
clearInterval(timer);
router.push({ name: "guide", query: {shopId: outTradEno.shopId} });
localStorage.removeItem('out_trade_no')
}else {
if (res.buy_type == 1) {
clearInterval(timer);
router.push({name: "buySuccess", query: outTradEno});
localStorage.removeItem('out_trade_no')
} else {
clearInterval(timer);
router.push({name: "success", query: outTradEno});
localStorage.removeItem('out_trade_no')
}
}
}).catch(() => {
clearInterval(timer);
localStorage.removeItem('out_trade_no')
});
});
} else if (res.status === "NO_SYNC") {
Dialog.confirm({title: '标题', message: '您有一笔未支付的订单', confirmButtonText: '去查看'}).then(() => {
clearInterval(timer);
location.href = `http://${window.location.host}/#/guidelines?pay_url=${encodeURI(window.localStorage.pay_url)}`
localStorage.removeItem('out_trade_no')
}).catch(() => {
clearInterval(timer);
localStorage.removeItem('out_trade_no')
});
}
})
}, 6000)
}
// 全局错误日志
const errorHandler = (error, vm) => {
Vue.prototype.$post(`api/client/report/errors/log`, {'routes_url': vm.$route.name, 'result_text': error.toString()})
const errorHandler = (error, vm)=>{
Vue.prototype.$post(`api/client/report/errors/log`,{'routes_url':vm.$route.name,'result_text':error.toString()})
}
Vue.config.errorHandler = errorHandler;
Vue.prototype.$throw = (error) => errorHandler(error, this);
Vue.prototype.$throw = (error)=> errorHandler(error,this);
Vue.prototype.$common = common
//VConsole关闭屏蔽代码
if (process.env.NODE_ENV != 'production') {
......@@ -122,16 +70,13 @@ router.beforeEach((to, from, next) => {
}
})
new Vue({
el: '#app',
router,
store,
components: {App},
components: { App },
template: '<App/>'
});
if (!Array.prototype.find) {
Array.prototype.find = function (predicate) {
'use strict';
......
......@@ -39,6 +39,7 @@ const router = new Router({
deep: 0,
}
},
{
path: '/extensionV1Shop',
name: 'extensionV1Shop',
......@@ -570,12 +571,6 @@ const router = new Router({
name: 'punchTheClock',
component: e => require(['@/components/punchTheClock'], e)
},
// 微信跳转支付宝
{
path: '/guidelines',
name: 'guidelines',
component: e => require(['@/components/buy/guidelines'], e)
},
{
path: '*',
component: () => import('@/components/error'),
......@@ -604,16 +599,6 @@ router.beforeEach((to, from, next) => {
next({ name: 'noWechat', query: { url: encodeURIComponent(to.fullPath) } });
}
}
/*let micromessenger = common.isWeixinBrowser();
if(micromessenger == 2){
alert(micromessenger);
alert(999999)
// location.href = `http://${ window.location.host }/#/guidelines`
next({ path: 'guidelines' })
return false;
}*/
// 移动端判断
store.dispatch('isMobile', browser.versions.mobile);
// 默认title
......@@ -625,9 +610,9 @@ router.beforeEach((to, from, next) => {
if (to.meta.title) {
document.title = to.meta.title;
}
let goOn = function () {
if (localStorage.getItem('retUrl') && localStorage.getItem('retUrl') !== null && localStorage.getItem('retUrl') !== '') {
console.log(localStorage.getItem('retUrl'))
let retUrl = localStorage.getItem('retUrl').toString();
localStorage.removeItem('retUrl');
next(retUrl);
......@@ -636,30 +621,22 @@ router.beforeEach((to, from, next) => {
}
};
if (window.location.href.indexOf('gdt_vid') > -1) {
console.log(3333333, common.getUrlParam())
localStorage.setItem('gdt_vid', common.getUrlParam().gdt_vid);
localStorage.setItem('cct_user_id', common.getUrlParam().cct_user_id);
localStorage.setItem('redeem_code', common.getUrlParam().cct_user_id);
// localStorage.setItem('redeem_code', common.getParamhref().redeem_code);
}
// 在支付宝里跳转
let micromessenger = common.isWeixinBrowser();
if(micromessenger == 2){
// alert("支付成功啦,请回到唱唱公众号继续操作!")
// location.href = "https://wechat-pre.changchangenglish.com/#/weixin"
location.href = "https://static-cdn.changchangenglish.com/public/images/alipay_success.png"
// location.href = "https://www.changchangenglish.com/zhifubao.html"
return ;
}
// extensionV1Shop
// extensionV1
if (to.name === 'starRankV2' || to.name === 'order' || to.name === 'buySuccess' || to.name === 'success' || to.name === 'guidelines' || to.name === 'spcShop' || to.name === 'mpShop' || to.name === 'extensionV1Shop' || to.name === 'extensionV1' || to.name === 'author' || to.name === 'bindMobile' || to.name === 'noWechat' || to.name === 'inspectorActivit' || to.name === 'buyDetail'|| to.name === 'passShop'|| to.name === 'ybIndex' ) {
if (to.name === 'spcShop' || to.name === 'mpShop' || to.name === 'extensionV1Shop' || to.name === 'extensionV1' || to.name === 'author' || to.name === 'bindMobile' || to.name === 'noWechat' || to.name === 'inspectorActivit' || to.name === 'buyDetail'|| to.name === 'passShop'|| to.name === 'ybIndex' ) {
// 无需登录的页面
console.log(899, to.name)
console.log(488)
next()
} else if (window.location.href.indexOf('token') > -1 && to.name === 'index') {
console.log(99000)
let token = common.getUrlParam().token || to.query.token;
console.log(common.getUrlParam())
console.log(to.name)
// debugger
store.dispatch('setToken', token);
getUserDetailApi().then(res => {
......
......@@ -431,8 +431,3 @@ const getNewCashUrl = `${_baseUrl}api/client/new/return/cash/`
export const getNewCashApi = function (element_id, category_id, periods_id, json) {
return Vue.prototype.$fetch(`${getNewCashUrl}${element_id}/${category_id}/${periods_id}`, json)
};
const getBillRefreshUrl = `${_baseUrl}api/client/bill/refresh`
export const getBillRefreshApi = function (json) {
return Vue.prototype.$fetch(getBillRefreshUrl, json)
};
......@@ -118,32 +118,5 @@ export default {
}
}
return newObj;
},
/**
* 判断是否在那个浏览器里
* @returns {number}
*/
isWeixinBrowser() {
var ui = 0
// 0 -> 微信 2 -> 支付宝 1 -> 其他
if (/MicroMessenger/.test(window.navigator.userAgent)) {
ui = 0
} else if (/AlipayClient/.test(window.navigator.userAgent)) {
ui = 2
} else {
ui = 1
}
return ui;
},
/**
* 获取链接后的参数
* @param name
* @param url
* @returns {RegExpExecArray | string}
*/
getParamByName(name, url) {
url = url || window.location;
var match = RegExp('[?&]' + name + '=([^&]*)').exec(url);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '))
}
}
.van-dialog {
border-radius: 15px;
padding-bottom: 25px;
.van-dialog__header {
opacity: 0;
}
.van-button__text {
display: inline-block;
width: 98px;
height: 44px;
color: #FFFFFF;
border-radius: 25px;
}
[class*=van-hairline]::after {
border: none
}
.van-button::before {
}
border-color: transparent;
//background-color: transparent;
.van-dialog__cancel {
.van-button__text {
background: #97A0BB;
}
}
.van-dialog__confirm {
.van-button__text {
background: #40A9FF;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment