index.php 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <div id="app" v-cloak>
  2. <el-card shadow="never" style="border:0;min-width: 1000px;" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  3. <div slot="header">
  4. <span>配置</span>
  5. </div>
  6. <div class="form_box" style="background: #ffffff;padding: 10px 30px;">
  7. <el-steps :active="active" :finish-status="result">
  8. <el-step :title="step_title"></el-step>
  9. <el-step title="授权"></el-step>
  10. <el-step title="完成"></el-step>
  11. </el-steps>
  12. <el-form v-if="active <= 1" ref="elForm" :disabled="disabled" :model="formData" :rules="rules" size="medium" label-width="100px" style="padding-top: 20px">
  13. <el-form-item label="应用ID" prop="alipay_app_id">
  14. <el-input v-model="formData.alipay_app_id" placeholder="请输入支付宝应用ID" clearable :style="{width: '100%'}">
  15. </el-input>
  16. </el-form-item>
  17. <el-form-item label="公司名称" prop="company">
  18. <el-input v-model="formData.company" placeholder="请输入公司名称" clearable :style="{width: '100%'}"></el-input>
  19. </el-form-item>
  20. <el-form-item label="联系人" prop="contacts">
  21. <el-input v-model="formData.contacts" placeholder="请输入联系人" clearable :style="{width: '100%'}"></el-input>
  22. </el-form-item>
  23. <el-form-item label="联系电话" prop="phone">
  24. <el-input v-model="formData.phone" placeholder="请输入联系电话" clearable :style="{width: '100%'}"></el-input>
  25. </el-form-item>
  26. <el-form-item label="状态" prop="phone" v-if="formData.status > 0">
  27. <span v-if="formData.status == 1" style="font-size: 18px">审核中</span>
  28. <span v-if="formData.status == 2" style="font-size: 18px">审核成功</span>
  29. <span v-if="formData.status == 3" style="font-size: 18px;color: red">审核失败:{{formData.reason}}</span>
  30. </el-form-item>
  31. <el-form-item size="large">
  32. <el-button
  33. :loading="submitLoading"
  34. class="button-item"
  35. size="small"
  36. type="primary"
  37. @click="submitForm">提交
  38. </el-button>
  39. </el-form-item>
  40. </el-form>
  41. <el-row v-if="active == 2" style="text-align:center">
  42. <img width="10%" src="https://pre.shuzixiangdao.com/web/uploads/images/thumbs/20211113/委托授权-1636797588887.png"/>
  43. <div>
  44. <div style="font-size: 18px;padding: 10px">审核通过</div>
  45. <a style="font-size: 18px" :href="formData.auth_url" target="_blank">点击前往授权</a>
  46. </div>
  47. </el-row>
  48. <el-row v-if="active == 3" style="font-size: 18px;font-weight: 600;padding-top: 15px">
  49. <el-row style="padding: 5px 0">
  50. <el-col :span="2"><div class="grid-content bg-purple">应用ID</div></el-col>
  51. <el-col :span="8"><div class="grid-content bg-purple">{{formData.alipay_app_id}}</div></el-col>
  52. </el-row>
  53. <el-row style="padding: 5px 0">
  54. <el-col :span="2"><div class="grid-content bg-purple">公司名称</div></el-col>
  55. <el-col :span="8"><div class="grid-content bg-purple">{{formData.company}}</div></el-col>
  56. </el-row>
  57. <el-row style="padding: 5px 0">
  58. <el-col :span="2"><div class="grid-content bg-purple">联系人</div></el-col>
  59. <el-col :span="8"><div class="grid-content bg-purple">{{formData.contacts}}</div></el-col>
  60. </el-row>
  61. <el-row style="padding: 5px 0">
  62. <el-col :span="2"><div class="grid-content bg-purple">联系方式</div></el-col>
  63. <el-col :span="8"><div class="grid-content bg-purple">{{formData.phone}}</div></el-col>
  64. </el-row>
  65. <hr>
  66. <el-row style="padding: 5px 0">
  67. <el-col :span="2"><div class="grid-content bg-purple">状态</div></el-col>
  68. <el-col :span="8"><div class="grid-content bg-purple">{{formData.statusText}}</div></el-col>
  69. </el-row>
  70. <el-row style="padding: 5px 0">
  71. <el-col :span="2"><div class="grid-content bg-purple">授权状态</div></el-col>
  72. <el-col :span="8"><div class="grid-content bg-purple">{{formData.authStatusText}}</div></el-col>
  73. </el-row>
  74. <el-row style="padding: 5px 0">
  75. <el-col :span="2"><div class="grid-content bg-purple">授权时间</div></el-col>
  76. <el-col :span="8"><div class="grid-content bg-purple">{{formData.auth_time|dateTimeFormat('Y-m-d H:i:s')}}</div></el-col>
  77. </el-row>
  78. </el-row>
  79. </div>
  80. </el-card>
  81. </div>
  82. <script>
  83. const app = new Vue({
  84. el: '#app',
  85. data() {
  86. return {
  87. active: 0,
  88. result: 'success',
  89. disabled: false,
  90. step_title: '申请',
  91. submitLoading: false,
  92. formData: {
  93. alipay_app_id: undefined,
  94. company: undefined,
  95. contacts: undefined,
  96. phone: undefined,
  97. },
  98. rules: {
  99. alipay_app_id: [{
  100. required: true,
  101. message: '请输入支付宝应用ID',
  102. trigger: 'blur'
  103. }],
  104. company: [{
  105. required: true,
  106. message: '请输入公司名称',
  107. trigger: 'blur'
  108. }],
  109. contacts: [{
  110. required: true,
  111. message: '请输入联系人',
  112. trigger: 'blur'
  113. }],
  114. phone: [{
  115. required: true,
  116. message: '请输入联系电话',
  117. trigger: 'blur'
  118. }],
  119. },
  120. };
  121. },
  122. created() {
  123. this.getConfig();
  124. },
  125. methods: {
  126. next() {
  127. if (this.active++ > 2) this.active = 0;
  128. },
  129. submitForm() {
  130. this.$refs['elForm'].validate(valid => {
  131. // TODO 提交表单
  132. if (valid) {
  133. this.submitLoading = true;
  134. this.formData.active = this.active;
  135. request({
  136. params: {
  137. r: 'alitopay/apply/edit',
  138. },
  139. method: 'post',
  140. data: this.formData,
  141. }).then(e => {
  142. this.submitLoading = false;
  143. if (e.data.code === 0) {
  144. this.$message.success(e.data.msg);
  145. this.getConfig();
  146. } else {
  147. this.$message.error(e.data.msg);
  148. }
  149. }).catch(e => {
  150. this.submitLoading = false;
  151. });
  152. } else {
  153. this.$message.error('部分参数验证不通过');
  154. }
  155. })
  156. },
  157. resetForm() {
  158. this.$refs['elForm'].resetFields()
  159. },
  160. getConfig(){
  161. this.submitLoading = true;
  162. request({
  163. params: {
  164. r: 'alitopay/apply/index',
  165. },
  166. method: 'get',
  167. }).then(e => {
  168. this.submitLoading = false;
  169. if (e.data.code === 0) {
  170. let data = e.data.data;
  171. console.log(data);
  172. this.formData = data;
  173. if(data.status == 1){
  174. // 申请中
  175. this.disabled = true
  176. this.active = 1;
  177. this.result = 'success';
  178. this.step_title = '审核中';
  179. }
  180. if(data.status == 3){
  181. // 申请失败
  182. this.active = 1;
  183. this.result = 'error';
  184. this.step_title = '审核失败';
  185. }
  186. // 授权
  187. if(data.status == 2 && data.auth_status == 1){
  188. //授权中
  189. this.active = 2;
  190. }
  191. if(data.status == 2 && data.auth_status == 2){
  192. //授权中
  193. this.active = 3;
  194. }
  195. } else {
  196. this.$message.error(e.data.msg);
  197. }
  198. }).catch(e => {
  199. this.submitLoading = false;
  200. });
  201. }
  202. }
  203. })
  204. </script>