完善提交体验版

master
李春波 2 years ago
parent 58981a1692
commit e857371bbd
  1. 37
      app/admin/controller/MiniProgramController.php
  2. 91
      app/common/service/wechat/MiniProgram.php
  3. 8
      front/src/api/miniprogram.js
  4. 50
      front/src/views/authorizer/detail.vue

@ -11,31 +11,20 @@ class MiniProgramController extends BaseController
public function detail(Request $request)
{
$id = $request->post('id');
$row = Authorizers::where('id', $id)->find();
$row = Authorizers::where('id', $id)->find()->toArray();
$miniprogram = new MiniProgram($row['platform_id']);
// $row['visit_status'] = $miniprogram->getVisitStatus($row['appid']);
$version = $miniprogram->getVersionInfo($row['appid']);
if (!empty($version['release_info'])) {
$version['release_info']['release_qrcode'] = base64_encode($miniprogram->getQrCode($row['appid']));
}
if (!empty($version['exp_info'])) {
$version['exp_info']['exp_qrcode'] = base64_encode($miniprogram->getExpQrCode($row['appid']));
}
// $json = [
// 'errcode' => 0,
// 'errmsg' => 'ok',
// 'auditid' => 1234567,
// 'status' => 4,
// 'reason' => '账号信息不合规范',
// 'ScreenShot' => 'xx|yy|zz',
// 'user_version' => 'V1.5',
// 'user_desc' => 'xxx',
// 'submit_audit_time' => '1640763673'
// ];
$version['audit_info'] = $miniprogram->getLatestAuditStatus($row['appid']);
// $version['audit_info'] = $json;
$row['version'] = $version;
$row['code_template'] = $miniprogram->getTemplate();
$version_detail = $miniprogram->getVersionDetail($row['appid']);
$row = array_merge($row, $version_detail);
return success($row);
}
public function commit(Request $request)
{
$id = $request->post('id');
$data = $request->post();
$row = Authorizers::where('id', $id)->find();
$miniprogram = new MiniProgram($row['platform_id']);
$result = $miniprogram->commit($row['appid'], $data);
return success($result);
}
}

@ -4,6 +4,11 @@ namespace app\common\service\wechat;
use app\admin\model\Authorizers;
use EasyWeChat\Kernel\Exceptions\InvalidConfigException;
use EasyWeChat\Kernel\Http\Response;
use EasyWeChat\Kernel\Support\Collection;
use GuzzleHttp\Exception\GuzzleException;
use Psr\Http\Message\ResponseInterface;
use Tinywan\ExceptionHandler\Exception\BadRequestHttpException;
class MiniProgram extends OpenPlatform
@ -14,6 +19,47 @@ class MiniProgram extends OpenPlatform
return $this->app->miniProgram($platform['appid'], $platform['refreshtoken']);
}
/**
* 获取当前小程序代码信息
* @param $appid
* @return array
* @throws GuzzleException
* @throws InvalidConfigException
* @throws BadRequestHttpException
*/
public function getVersionDetail($appid): array
{
try {
$result = [];
$version = $this->getVersionInfo($appid);
if (!empty($version['release_info'])) {
$version['release_info']['release_qrcode'] = base64_encode($this->getQrCode($appid));
}
if (!empty($version['exp_info'])) {
$version['exp_info']['exp_qrcode'] = base64_encode($this->getExpQrCode($appid));
}
$version['audit_info'] = $this->getLatestAuditStatus($appid);
$result['version'] = $version;
$result['code_template'] = $this->getTemplate();
/* $json = [
'errcode' => 0,
'errmsg' => 'ok',
'auditid' => 1234567,
'status' => 4,
'reason' => '账号信息不合规范',
'ScreenShot' => 'xx|yy|zz',
'user_version' => 'V1.5',
'user_desc' => 'xxx',
'submit_audit_time' => '1640763673'
];
$version['audit_info'] = $json;*/
return $result;
} catch (BadRequestHttpException $exception) {
throw new BadRequestHttpException($exception->getMessage());
}
}
public function getToken($appid): array
{
try {
@ -23,29 +69,74 @@ class MiniProgram extends OpenPlatform
}
}
/**
* 获取小程序状态
* @param $appid
* @return mixed
*/
public function getVisitStatus($appid)
{
return $this->getMiniProgram($appid)->base->httpPostJson('wxa/getvisitstatus', []);
}
/**
* 获取版本信息
* @param $appid
* @return mixed
*/
public function getVersionInfo($appid)
{
return $this->getMiniProgram($appid)->base->httpPostJson('wxa/getversioninfo', []);
}
/**
* 获取小程序码
* @param $appid
* @return array|Collection|object|ResponseInterface|string
*/
public function getQrCode($appid)
{
return $this->getMiniProgram($appid)->app_code->getUnlimit('wxcomponent');
}
/**
* 获取体验版二维码
* @param $appid
* @return Response
* @throws InvalidConfigException
* @throws GuzzleException
*/
public function getExpQrCode($appid)
{
return $this->getMiniProgram($appid)->code->getQrCode();
}
/**
* 获取最后一次审核状态
* @param $appid
* @return array|Collection|object|ResponseInterface|string
* @throws InvalidConfigException
*/
public function getLatestAuditStatus($appid)
{
return $this->getMiniProgram($appid)->code->getLatestAuditStatus();
}
/**
* 上传代码并生成体验版
* @param $appid
* @param $data
* @return array|Collection|object|ResponseInterface|string
* @throws GuzzleException
* @throws InvalidConfigException
*/
public function commit($appid, $data)
{
$template_id = $data['template_id'];
$ext_json = $data['ext_json'];
$user_version = $data['user_version'];
$user_desc = $data['user_desc'];
return $this->getMiniProgram($appid)->code->commit($template_id, $ext_json, $user_version, $user_desc);
}
}

@ -2,6 +2,7 @@ import request from '@/utils/request'
const api = {
detail: '/miniprogram/detail',
commit: '/miniprogram/commit',
}
export function getDetail(parameter) {
@ -12,3 +13,10 @@ export function getDetail(parameter) {
})
}
export function commit(parameter) {
return request({
url: api.commit,
method: 'post',
data: parameter
})
}

@ -56,8 +56,8 @@
<a-card :bordered="false" :loading="loading" title="体验版本">
<template v-if="exp_info">
<a-dropdown slot="extra">
<a-menu slot="overlay">
<a-menu-item v-for="(item) in audit_option" :key="item.value">{{ item.content }}</a-menu-item>
<a-menu slot="overlay" @click="handleExpButton">
<a-menu-item v-for="(item) in exp_options" :key="item.value">{{ item.content }}</a-menu-item>
</a-menu>
<a-button type="primary"> 操作
<a-icon type="down"/>
@ -68,7 +68,7 @@
<a-descriptions-item :span="3" label="版本号">
{{ exp_info['exp_version'] }}
</a-descriptions-item>
<a-descriptions-item :span="3" label="发布时间">
<a-descriptions-item :span="3" label="提交时间">
{{ exp_info['exp_time'] | momentUnix }}
</a-descriptions-item>
<a-descriptions-item :span="3" label="版本描述">
@ -92,6 +92,7 @@
<a-modal
:confirm-loading="modal_loading"
:visible="modal_visible"
:maskClosable="false"
title="提交代码"
width="700px"
@cancel="modalCancel"
@ -136,20 +137,21 @@
</template>
<script>
import {getDetail} from '@/api/miniprogram'
import {commit, getDetail} from '@/api/miniprogram'
import data from "@/config/data";
export default {
name: 'Version',
data() {
return {
id: null,
enum_data: data,
release_info: undefined,
exp_info: undefined,
audit_info: {},
code_template: [],
loading: true,
modal_visible: true,
modal_visible: false,
modal_loading: false,
formLayout: {
labelCol: {
@ -177,14 +179,32 @@ export default {
},
modalOk() {
// this.modal_visible = false
this.modal_loading = true
this.form.validateFields((errors, values) => {
console.log(errors, values)
commit({id: this.id, ...values}).then(res => {
this.getDetail(this.id)
this.modal_visible = false
this.$message.success('提交成功')
}).finally(() => {
this.modal_loading = false
})
})
},
modalCancel() {
this.modal_visible = false
},
handleExpButton(option) {
const {key} = option
switch (key) {
case 1: {
//
this.modal_visible = true
}
case 2: {
//
}
}
}
},
computed: {
audit_option() {
@ -210,11 +230,25 @@ export default {
}]
}
return []
},
exp_options() {
const arr = [{
content: '重新提交代码',
value: 1,
}]
if (this.audit_info?.status !== 2) {
arr.push({
content: '提交审核',
value: 2,
})
}
return arr
}
},
created() {
const {id} = this.$route.query
this.getDetail(id)
this.id = id
this.getDetail(this.id)
},
}
</script>

Loading…
Cancel
Save