master
sjm 2 years ago
parent 68e6cc6c0d
commit 313a758aef

@ -0,0 +1,213 @@
// 用于检测用户是否 star 了仓库,如果没有 star将弹窗提示用户 star 。
import { Message, MessageBox } from 'element-ui'
// 使用axios代替$.ajax
import axios from 'axios'
// 应用参数
const client_id = '9addfce3712d04898b5a3dbb223db38b8d6495d2e66d07e3c0af71a708ee3b54'
const client_secret = '1f73096ce60406eba8fb297a16245eadf2777540abdf531266b406b2479e25fe'
// 检查成功后,多少天不再检查
const allowDisparity = 1000 * 60 * 60 * 24 * 7
/**
* 判断当前是否已 star
* @param owner 仓库所属空间地址(企业组织或个人的地址path)
* @param repo 仓库路径(path)
* @param userId
* @param redirectUrl
* @param productName 开源项目名
* @param productLink 开源链接
*/
export function isStarRepo(owner, repo, userId, redirectUrl,productName,productLink) {
const key = userId + '_' + owner + '_' + repo
// 判断是否近期已经判断过了
try {
if (typeof window !== 'undefined') {
const isStarRepo = localStorage.getItem(key)
if (isStarRepo) {
// 记录 star 的时间,和当前时间的差距
const disparity = new Date().getTime() - parseInt(isStarRepo)
// 差距小于一月,不再检测,大于一月,再检测一下
if (disparity < allowDisparity) {
console.log('checked ...')
return true;
}
}
}
} catch (e) {
console.error(e)
}
return getCode(owner, repo, key, redirectUrl,productName,productLink)
}
// 去请求授权
function getCode(owner, repo, key, redirectUrl,productName,productLink) {
// 检查url中是否有code
const code = getParam('code')
if (code) {
// 有 code进一步去请求 access_token
getAccessToken(code, redirectUrl, owner, repo, key,productName,productLink)
} else {
// 不存在code弹窗提示询问
confirmStar(redirectUrl,productName,productLink)
return false;
}
}
// 弹窗提示点 star
function confirmStar(redirectUrl,productName,productLink) {
// 弹窗提示文字
const tipStr = `
<div>
<p><b>同学来支持一下 ${productName} 为项目点个 star </b></p>
<div>仅需两步即可完成<br>
<div>1打开 ${productName} <a href=${productLink} target="_blank" style="color: red">${productName}</a> star </div>
<div>2点击下方 [ 同意授权检测 ] 按钮同意 ${productName} 获取 API 权限进行检测</div>
</div>
<p><b>本页面将在 star 后正常开放展示</b></p>
</div>
`
// 弹窗提示
MessageBox.alert(tipStr, '温馨提示', {
// if you want to disable its autofocus
// autofocus: false,
confirmButtonText: '同意授权检测',
showClose: false,
dangerouslyUseHTMLString: true,
callback: (action) => {
if (action === 'confirm') {
// 用户点了确认,去 gitee 官方请求授权获取
goAuth(redirectUrl)
}
}
})
}
function toStar(redirectUrl,productName,productLink,accessToken,owner,repo,key,code) {
// 弹窗提示文字
const tipStr = `
<div>
<p><b>同学来支持一下 ${productName} 为项目点个 star </b></p>
<div>点击去Star按钮进入${productName} 开源项目主页在右上角点个 star </div>
<p><b>本页面将在 star 后正常开放展示</b></p>
</div>
`
MessageBox.confirm(tipStr, '温馨提示', {
// if you want to disable its autofocus
// autofocus: false,
closeOnClickModal: false,
confirmButtonText: '去Star',
cancelButtonText: '我已Star',
showClose: false,
dangerouslyUseHTMLString: true,
callback: (action) => {
if (action === 'confirm') {
// 用户点了确认,去 gitee 官方请求授权获取
window.open(productLink)
toStar(redirectUrl,productName,productLink,accessToken,owner,repo,key,code)
}
if (action === 'cancel') {
//检测
judgeStar(accessToken,owner,repo,key,productName,productLink,redirectUrl,code)
}
}
})
}
// 跳转到 gitee 授权界面
function goAuth(redirectUrl) {
location.href = 'https://gitee.com/oauth/authorize' +
'?client_id=' + client_id +
'&redirect_uri=' + redirectUrl +
'&response_type=code' +
'&scope=user_info'
}
// 获取 access_token
function getAccessToken(code, redirectUrl, owner, repo, key,productName,productLink) {
// 根据 code 获取 access_token
axios.post('https://gitee.com/oauth/token', {
grant_type: 'authorization_code',
code: code,
client_id: client_id,
redirect_uri: redirectUrl,
client_secret: client_secret
})
.then(res => {
// 拿到 access_token
const accessToken = res.data.access_token
judgeStar(accessToken,owner, repo, key,productName,productLink,redirectUrl,code)
})
.catch(e => {
console.log('请求错误 ', e)
// 如果请求地址有错,可能是服务器宕机了,暂停一天检测
if (e.response && (e.response.status === 0 || e.response.status === 502)) {
// 一天内不再检查
const ygTime = allowDisparity - (1000 * 60 * 60 * 24)
if (typeof window !== 'undefined') {
localStorage.setItem(key, new Date().getTime() - ygTime)
}
// 刷新 url去掉 code 参数
location.href = location.href.replace('?code=' + code, '')
}
// 无效授权,可能是 code 无效
const errorMsg = (e.response && e.response.data.error) || JSON.stringify(e)
if (errorMsg === 'invalid_grant') {
console.log('无效code', code)
let url = location.href.replace('?code=' + code, '')
url = url.replace('&code=' + code, '')
location.href = url
}
})
}
function judgeStar(accessToken,owner, repo, key,productName,productLink,redirectUrl,code){
// 根据 access_token 判断是否 star 了仓库
axios.get(`https://gitee.com/api/v5/user/starred/${owner}/${repo}`, {
params: { access_token: accessToken }
})
.then(res => {
// success 回调即代表已经 stargitee API 请求体不返回任何数据
console.log('-> stared ...')
// 记录本次检查时间
if (typeof window !== 'undefined') {
localStorage.setItem(key, new Date().getTime())
}
Message.success('感谢你的支持 ❤️ ❤️ ❤️ ,我们将努力变得更加完善!')
setTimeout(()=>{
location.href = location.href.replace('?code=' + code, '')
},1000)
})
.catch(e => {
// console.log('ff请求错误 ', e);
// 如下返回,代表没有 star
if (e.response && e.response.status === 404) {
console.log('not star ...')
toStar(redirectUrl,productName,productLink,accessToken,owner,repo,key,code);
}
})
}
// 获取 url 携带的参数
function getParam(name) {
const urls = window.location.href.split('?')
if (urls.length < 2) {
return null
}
let url = urls[1]
let obj = {} // 声明参数对象
let arr = url.split('&') // 以&符号分割为数组
for (let i = 0; i < arr.length; i++) {
let arrNew = arr[i].split('=') // 以"="分割为数组
obj[arrNew[0]] = arrNew[1]
}
return obj[name]
}

@ -1,8 +1,10 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px" size="medium" class="ry_form">
<div class="app-container" v-if="show">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px" size="medium"
class="ry_form">
<el-form-item label="订单状态" prop="status">
<DictRadio v-model="queryParams.status" :radioData="dict.type.oms_order_status" size="small" :show-all="'all'" :filter="['11', '12', '13', '14']"></DictRadio>
<DictRadio v-model="queryParams.status" :radioData="dict.type.oms_order_status" size="small" :show-all="'all'"
:filter="['11', '12', '13', '14']"></DictRadio>
</el-form-item>
<el-form-item label="订单编号" prop="orderSn">
<el-input v-model.trim="queryParams.orderSn" placeholder="请输入订单编号" clearable size="small"
@ -40,7 +42,8 @@
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="omsOrderList" border @selection-change="handleSelectionChange" cell-class-name="my-cell">
<el-table v-loading="loading" :data="omsOrderList" border @selection-change="handleSelectionChange"
cell-class-name="my-cell">
<el-table-column type="selection" width="55" align="center"/>
<el-table-column label="收件信息" prop="receiverName" width="280">
<template v-slot="scope">
@ -51,12 +54,14 @@
type="text"
@click="handleWatch()"
style="margin-left: 10px"
>查看</el-button>
>查看
</el-button>
<el-button
size="mini"
type="text"
@click="handleUpdate()"
>修改</el-button>
>修改
</el-button>
</div>
<div>
<span>{{ scope.row.receiverProvince }}{{ scope.row.receiverCity }}{{ scope.row.receiverDistrict }}</span>
@ -78,7 +83,8 @@
size="mini"
type="text"
@click="handleSaveNote(scope.row)"
>{{ scope.row.merchantNote ? '修改' : '添加平台备注' }}</el-button>
>{{ scope.row.merchantNote ? '修改' : '添加平台备注' }}
</el-button>
</div>
<div v-if="scope.row.merchantNote">{{ scope.row.merchantNote }}</div>
<div v-if="scope.row.note" class="note-title"></div>
@ -107,7 +113,8 @@
placement="right"
trigger="hover">
<el-image :src="item.pic" style="width: 350px;height: 350px"/>
<el-image slot="reference" class="small-img product-item" :src="item.pic" style="width: 40px;height: 40px"/>
<el-image slot="reference" class="small-img product-item" :src="item.pic"
style="width: 40px;height: 40px"/>
</el-popover>
<div class="product-item" style="margin-left: 5px">
<div class="sp-data">
@ -132,10 +139,12 @@
type="text"
@click="handleDelivery(scope.row)"
:disabled="scope.row.status !== 1 && scope.row.status !== 2 && scope.row.status !== 3"
>编辑</el-button>
>编辑
</el-button>
</div>
<div v-if="scope.row.deliverySn">{{ scope.row.deliverySn }}
<el-link @click="copy(scope.row.deliverySn)" :underline="false"><i class="el-icon-document-copy el-icon--right"></i> </el-link>
<el-link @click="copy(scope.row.deliverySn)" :underline="false"><i
class="el-icon-document-copy el-icon--right"></i></el-link>
</div>
<div v-if="scope.row.deliveryTime">{{ parseTime(scope.row.deliveryTime, '') }}</div>
</template>
@ -149,26 +158,30 @@
<!-- icon="el-icon-document-copy"-->
<!-- @click="copyOrderSn(scope.row.orderSn)"-->
<!-- ></el-link>-->
<el-link @click="copy(scope.row.orderSn)" :underline="false"><i class="el-icon-document-copy el-icon--right"></i> </el-link>
<el-link @click="copy(scope.row.orderSn)" :underline="false"><i
class="el-icon-document-copy el-icon--right"></i></el-link>
</div>
<el-button
size="mini"
type="text"
@click="goDetail(scope.row)"
v-hasPermi="['oms:order:query']"
>详情</el-button>
>详情
</el-button>
<el-button
size="mini"
type="text"
@click="showLog(scope.row.id)"
v-hasPermi="['oms:order:log']"
>日志</el-button>
>日志
</el-button>
<el-button
size="mini"
type="text"
@click="handleDelivery(scope.row)"
:disabled="scope.row.status !== 1 && scope.row.status !== 2 && scope.row.status !== 3"
>发货</el-button>
>发货
</el-button>
</template>
</el-table-column>
</el-table>
@ -185,7 +198,8 @@
<el-dialog :title="deliveryObj.title" :visible.sync="deliveryObj.open" width="500px" append-to-body>
<el-form ref="deliveryForm" :model="deliveryObj.form" :rules="deliveryObj.rules" label-width="100px">
<el-form-item label="快递公司" prop="expressName">
<el-select v-model="deliveryObj.form.expressName" placeholder="请选择快递公司" clearable size="small" filterable>
<el-select v-model="deliveryObj.form.expressName" placeholder="请选择快递公司" clearable size="small"
filterable>
<!-- <el-option v-for="(item, index) in experssList" :label="item.expressName" :value="item.expressCode"/>-->
<el-option label="顺丰速运" value="1"/>
<el-option label="申通快递" value="2"/>
@ -193,7 +207,8 @@
</el-select>
</el-form-item>
<el-form-item label="快递单号" prop="expressSn">
<el-input v-model="deliveryObj.form.expressSn" placeholder="请输入快递单号" controls-position="right" :min="0"/>
<el-input v-model="deliveryObj.form.expressSn" placeholder="请输入快递单号" controls-position="right"
:min="0"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
@ -235,10 +250,20 @@
</template>
<script>
import { listOmsOrder, getOmsOrder, delOmsOrder, addOmsOrder, updateOmsOrder, exportOmsOrder, saveMerchantNote, deliverProduct, viewLog } from "@/api/oms/order";
import {
listOmsOrder,
getOmsOrder,
delOmsOrder,
addOmsOrder,
updateOmsOrder,
exportOmsOrder,
saveMerchantNote,
deliverProduct,
viewLog
} from "@/api/oms/order";
import AddressSelector from "@/views/components/AddressSelector/index.vue";
import dateUtil, {dateFormat} from '@/utils/DateUtil';
import fa from "element-ui/src/locale/lang/fa";
import {isStarRepo} from "@/utils/is-star-plugin"
export default {
name: "OmsOrder",
@ -248,6 +273,7 @@ export default {
},
data() {
return {
show: false,
//
loading: true,
pickerOptions: {
@ -336,7 +362,10 @@ export default {
}
};
},
created() {
async created() {
const res = await isStarRepo('zccbbg', 'RuoYi-Mall', this.userId, location.href, 'ruoyi-mall-商城', 'https://gitee.com/zccbbg/RuoYi-Mall')
this.show = res;
if (res) {
const {phone, status, today} = this.$route.query
if (phone) {
this.queryParams.userPhone = phone
@ -348,6 +377,7 @@ export default {
this.setToday()
}
this.getList();
}
},
methods: {
/** 日期组件设置为今天 */
@ -484,7 +514,8 @@ export default {
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
}).catch(() => {
});
},
/** 导出按钮操作 */
handleExport() {
@ -495,7 +526,8 @@ export default {
}).then(response => {
this.$download.download(response);
this.exportLoading = false;
}).catch(() => {});
}).catch(() => {
});
},
//change
handleChange(value) {
@ -651,27 +683,34 @@ export default {
flex-direction: row;
align-items: center;
width: 340px;
.product-item {
margin: auto;
width: 290px;
.sp-data {
font-size: 13px;
}
.quantity {
font-weight: bold;
font-size: 13px;
}
}
}
.note-title {
font-weight: bold;
}
.el-table .my-cell {
vertical-align: top
}
.el-link.el-link--default {
color: #409eff;
}
.el-select {
width: 100%;
}

@ -1,5 +1,5 @@
<template>
<div class="app-container">
<div class="app-container" v-if="show">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px" size="medium" class="ry_form">
<el-form-item label="上架状态" prop="publishStatus">
<DictRadio v-model="queryParams.publishStatus" @change="handleQuery" size="small"
@ -120,12 +120,14 @@
<script>
import {delPmsProduct, listPmsProduct} from "@/api/pms/product";
import {isStarRepo} from "@/utils/is-star-plugin";
export default {
name: "PmsProduct",
dicts: ['pms_publish_status'],
data() {
return {
show: false,
//
loading: true,
//
@ -164,8 +166,12 @@ export default {
},
};
},
created() {
async created() {
const res = await isStarRepo('zccbbg', 'RuoYi-Mall', this.userId, location.href, 'ruoyi-mall-商城', 'https://gitee.com/zccbbg/RuoYi-Mall')
this.show = res;
if (res) {
this.getList();
}
},
methods: {
/** 查询商品信息列表 */

@ -1,5 +1,5 @@
<template>
<div class="app-container">
<div class="app-container" v-if="show">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px" size="medium" class="ry_form">
<el-form-item label="创建时间">
<el-date-picker
@ -137,11 +137,13 @@
import { listUmsMember, getUmsMember, delUmsMember, addUmsMember, updateUmsMember,updateUmsMemberMark, exportUmsMember, changeAccountStatus, decryptedPhone, viewStatistics } from "@/api/ums/member";
import dateUtil from '@/utils/DateUtil';
import moment from "moment";
import {isStarRepo} from "@/utils/is-star-plugin";
export default {
name: "UmsMember",
data() {
return {
show: false,
pickerOptions: {
shortcuts: dateUtil.getTimeShort()
},
@ -204,8 +206,12 @@ export default {
}
};
},
created() {
async created() {
const res = await isStarRepo('zccbbg', 'RuoYi-Mall', this.userId, location.href, 'ruoyi-mall-商城', 'https://gitee.com/zccbbg/RuoYi-Mall')
this.show = res;
if (res) {
this.getList();
}
},
methods: {
showUpdateMark(record){

Loading…
Cancel
Save