diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php index b49906c3..4c3155c9 100755 --- a/app/Controllers/UserController.php +++ b/app/Controllers/UserController.php @@ -887,6 +887,7 @@ class UserController extends BaseController $user->invite_num += $num; $user->money -= $amount; $user->save(); + $res['invite_num'] = $user->invite_num; $res['ret'] = 1; $res['msg'] = "邀请次数添加成功"; return $response->getBody()->write(json_encode($res)); diff --git a/app/Controllers/VueController.php b/app/Controllers/VueController.php index c7dc7638..018ed6a6 100644 --- a/app/Controllers/VueController.php +++ b/app/Controllers/VueController.php @@ -162,6 +162,7 @@ class VueController extends BaseController { "paybacks" => $paybacks, "paybacks_sum" => $paybacks_sum, "invitePrice" => Config::get('invite_price'), + "customPrice" => Config::get('custom_invite_price'), ); $res['ret'] = 1; @@ -208,4 +209,23 @@ class VueController extends BaseController { return $response->getBody()->write(json_encode($res)); } + public function getNewInviteCode($request, $response, $args) + { + $user = $this->user; + $user->clear_inviteCodes(); + $code = InviteCode::where('user_id', $this->user->id)->first(); + if ($code == null) { + $this->user->addInviteCode(); + $code = InviteCode::where('user_id', $this->user->id)->first(); + } + + $res['arr'] = array( + "code" => $code, + ); + + $res['ret'] = 1; + + return $response->getBody()->write(json_encode($res)); + } + } \ No newline at end of file diff --git a/config/routes.php b/config/routes.php index 90fa9458..5123402d 100755 --- a/config/routes.php +++ b/config/routes.php @@ -377,6 +377,7 @@ $app->get('/getuserinviteinfo', 'App\Controllers\VueController:getUserInviteInfo $app->get('/getusershops', 'App\Controllers\VueController:getUserShops'); $app->get('/getcredit', 'App\Controllers\VueController:getCredit'); $app->get('/getnewsubtoken', 'App\Controllers\VueController:getNewSubToken'); +$app->get('/getnewinvotecode', 'App\Controllers\VueController:getNewInviteCode'); /** * chenPay diff --git a/public/theme/material/css/index.css b/public/theme/material/css/index.css index 396b4758..8990a4ef 100755 --- a/public/theme/material/css/index.css +++ b/public/theme/material/css/index.css @@ -53,6 +53,10 @@ a { text-align: right; } +.text-red { + color: #D1335B; +} + .margin-nobottom { margin-bottom: 0 !important; } @@ -230,7 +234,8 @@ button.btn-user.index-btn-active { input.checkbox, .buy-submit, .font-light, -.list-shop { +.list-shop, +.user-config { transition: all .3s; } @@ -280,15 +285,18 @@ input.checkbox, } .auth-submit:hover, -.auth-submit:focus, { +.auth-submit:focus, + { background-color: #d6d6d6; border-color: #d6d6d6; } -.buy-submit:disabled { +.buy-submit:disabled, +button.tips:disabled { color: #858585; border-color: #858585; cursor: not-allowed; + background-color: transparent; } .auth, @@ -534,6 +542,11 @@ select { border-color: #faad14; } +.tips-gold-trans.tips-gold { + color: white; + background-color: #faad14; +} + .tips-green { color: #52c41a; border-color: #52c41a; @@ -549,6 +562,14 @@ select { border-color: #D1335B; } +.font-red-trans { + color: #D1335B; +} + +button.tips { + background-color: transparent; +} + .tips-blue:hover, .tips-gold:hover, .tips-green:hover, @@ -629,6 +650,38 @@ select { font-size: 14px; } +.invite-tools { + position: relative; + margin-left: .75rem; +} + +.invite-tools .tips.tips-red { + position: relative; + top: 1px; +} + +.invite-tools.tips-green { + padding: 3.5px .7rem; + bottom: 1px; + margin-left: .55rem; +} + +.invite-link { + width: 100%; +} + +.user-invite-title .uim-tooltip { + width: 100%; +} + +.user-invite-title .uim-tooltip button { + border: 0; +} + +.user-invite-title .tips { + position: relative; +} + .list-shop { padding: .5rem; font-size: 1.2rem; @@ -641,7 +694,7 @@ select { } .list-shop:hover { - transform: translate3D(1rem,0,0); + transform: translate3D(1rem, 0, 0); } .coupon-checker { @@ -704,7 +757,8 @@ button[name=reset] { word-break: break-all; } -.sublink-reset.tips-blue { +.sublink-reset.tips-blue, +.invite-reset.tips-blue { background-color: #1997c6; color: white; } @@ -781,6 +835,15 @@ button[name=reset] { .link-reset .uim-tooltip-top { width: 230px; } + + .invite-link { + width: 450px; + } + + .user-invite-title .tips { + margin-bottom: .5rem; + margin-left: .75rem; + } } @media screen and (min-width:48em) { @@ -1067,7 +1130,7 @@ button.uim-modal-confirm { /* switch */ -.uim-switch-body { +.uim-switch-body { background-color: #ccc; border-radius: 25px; cursor: pointer; diff --git a/resources/views/material/index.tpl b/resources/views/material/index.tpl index 94a29ca9..e842bae4 100755 --- a/resources/views/material/index.tpl +++ b/resources/views/material/index.tpl @@ -224,7 +224,10 @@ const UserTmp = { }, SET_USERMONEY (state,number) { state.userCon.money = number; - } + }, + SET_INVITE_NUM (state,number) { + state.userCon.invite_num = number; + }, }, actions: { @@ -1078,12 +1081,69 @@ const UserInvite = { mixins: [userMixin,storeMap], template: /*html*/ `
-
邀请链接
+
+
邀请链接
+
+ + + + + +
+
确认购买 $[toolInputContent]$ 个吗?总价为 ¥$[totalPrice]$
+ 确认定制链接后缀为 $[toolInputContent]$ 吗?价格为 ¥$[customPrice]$ +
+ + +
+
+
+
+
+ +
+
+ ¥$[invitePrice]$/次 + 总价:¥$[totalPrice]$ +
+
+ 价格:¥$[customPrice]$ +
+
+
+
- -
邀请链接剩余次数: $[userCon.invite_num]$次
+
+ + + + + +
+ 确定要重置邀请链接? +
+ + +
+
+
+
+
+ + + +
+
邀请链接剩余次数: $[userCon.invite_num]$次 + + + +

$[userCon.user_name]$,您不是VIP暂时无法使用邀请链接,

@@ -1095,17 +1155,207 @@ const UserInvite = { computed: { inviteLink: function() { return this.baseURL + '/#/auth/register?code=' + this.code; - } + }, + totalPriceCa: function() { + return parseInt(this.toolInputContent)*parseInt(this.invitePrice); + }, + totalPrice: function() { + return isNaN(this.totalPriceCa) ? '' : this.totalPriceCa; + }, }, data: function() { return { + oldCode: '', code: '', + invitePrice: '', + customPrice: '', + toolInputContent: '', + placeholder: '', + toolInputType: '', + orderCheckContent: '', + inviteResetConfirm: false, + inviteLinkTrans: false, + inviteTimeTrans: false, + showToolInput: false, + isToolDisabled: false, + showOrderCheck: false, + theUnWatch: '', } }, + methods: { + destoryWatch() { + if (this.theUnWatch !== '') { + this.theUnWatch(); + } + }, + showInviteReset() { + this.inviteResetConfirm = true; + }, + hideInviteReset() { + this.inviteResetConfirm = false; + }, + showLinkTrans() { + this.inviteLinkTrans = true; + setTimeout(() => { + this.inviteLinkTrans = false; + }, 300); + }, + showInviteTimeTrans() { + this.inviteTimeTrans = true; + setTimeout(() => { + this.inviteTimeTrans = false; + }, 300); + }, + resetInviteLink() { + _get('/getnewinvotecode','include').then((r)=>{ + console.log(r); + this.code = r.arr.code.code; + this.hideInviteReset(); + this.showLinkTrans(); + let callConfig = { + msg: '已重置您的邀请链接,复制您的邀请链接发送给其他人!', + icon: 'fa-bell', + time: 1500, + } + tmp.dispatch('CALL_MSGR',callConfig); + }); + }, + hideToolInput() { + this.showToolInput = false; + this.isToolDisabled = false; + this.hideOrderCheck(); + this.destoryWatch(); + setTimeout(() => { + this.toolInputContent = ''; + }, 300); + }, + submitToolInput() { + switch(this.toolInputType) { + case 'buy': + this.buyOrdercheck(); + break; + case 'custom': + this.customOrderCheck(); + break; + } + }, + showBuyToolInput() { + this.showToolInput = true; + this.isToolDisabled = true; + this.placeholder = '输入购买数量'; + this.toolInputType = 'buy'; + }, + showCustomToolInput() { + this.showToolInput = true; + this.isToolDisabled = true; + this.placeholder = '输入链接后缀'; + this.toolInputType = 'custom'; + let unwatchCustom = this.$watch('toolInputContent',function(newVal, oldVal) { + this.code = newVal; + this.oldCode = oldVal; + }); + this.theUnWatch = unwatchCustom; + }, + hideOrderCheck() { + this.showOrderCheck = false; + }, + buyOrdercheck() { + if (isNaN(parseInt(this.toolInputContent)) || this.toolInputContent === '') { + let callConfig = { + msg: '请输入数字', + icon: 'fa-times-circle-o', + time: 1500, + } + tmp.dispatch('CALL_MSGR',callConfig); + } else { + this.showOrderCheck = true; + } + }, + customOrderCheck() { + if (this.toolInputContent === '') { + let callConfig = { + msg: '后缀不能为空', + icon: 'fa-times-circle-o', + time: 1500, + } + tmp.dispatch('CALL_MSGR',callConfig); + } else { + this.showOrderCheck = true; + } + }, + submitOrder() { + switch(this.toolInputType) { + case 'buy': + this.buyInvite(); + break; + case 'custom': + this.customInvite(); + break; + } + }, + buyInvite() { + let ajaxBody = { + num: parseInt(this.toolInputContent), + } + _post('/user/buy_invite',JSON.stringify(ajaxBody),'include').then((r)=>{ + this.hideToolInput(); + if(r.ret) { + this.resetCredit(); + this.showInviteTimeTrans(); + tmp.commit('SET_INVITE_NUM',r.invite_num); + let callConfig = { + msg: r.msg, + icon: 'fa-check-square-o', + time: 1000, + }; + tmp.dispatch('CALL_MSGR',callConfig); + } else { + let callConfig = { + msg: r.msg, + icon: 'fa-times-circle-o', + time: 1000, + }; + tmp.dispatch('CALL_MSGR',callConfig); + } + }); + }, + customInvite() { + this.hideToolInput(); + let ajaxBody = { + customcode: this.toolInputContent, + }; + _post('/user/custom_invite',JSON.stringify(ajaxBody),'include').then((r)=>{ + if (r.ret) { + console.log(r); + this.resetCredit(); + this.showLinkTrans(); + this.code = this.toolInputContent; + let callConfig = { + msg: r.msg, + icon: 'fa-check-square-o', + time: 1000, + }; + tmp.dispatch('CALL_MSGR',callConfig); + } else { + let callConfig = { + msg: r.msg, + icon: 'fa-times-circle-o', + time: 1000, + }; + tmp.dispatch('CALL_MSGR',callConfig); + } + }); + }, + }, + watch: { + toolInputType: 'destoryWatch', + }, mounted() { _get('getuserinviteinfo','include').then((r)=>{ console.log(r); this.code = r.inviteInfo.code.code; + this.invitePrice = r.inviteInfo.invitePrice; + this.customPrice = r.inviteInfo.customPrice; console.log(this.userCon); }); } @@ -1327,7 +1577,7 @@ const Panel = {

VIP等级

Lv. $[userCon.class]$

余额

-

$[userCon.money]$

+

$[userCon.money]$

@@ -1366,7 +1616,7 @@ const Panel = {
-
+
订阅链接 @@ -1512,6 +1762,7 @@ const Panel = { resetConfirm: false, }, subLinkTrans: false, + userCreditTrans: false, tipsLink: [ { name: '端口', @@ -1728,6 +1979,9 @@ const Panel = { currentDlType: 'SSR', } }, + watch: { + 'userCon.money': 'showCreditTrans', + }, methods: { logout() { let callConfig = { @@ -1778,6 +2032,12 @@ const Panel = { tmp.dispatch('CALL_MSGR',callConfig); }); }, + showCreditTrans() { + this.userCreditTrans = true; + setTimeout(() => { + this.userCreditTrans = false; + }, 300); + }, }, mounted() { let self = this;