serviceModel.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <div class="chioseWrap">
  3. <el-form :inline="true" ref="payForm" :model="payForm">
  4. <el-form-item
  5. prop="payType"
  6. :rules="[
  7. { required: true, message: '请选择支付方式', trigger: 'change' }
  8. ]"
  9. >
  10. <el-select
  11. v-model.trim="payForm.payType"
  12. style="width: 180px"
  13. clearable
  14. filterable
  15. placeholder="请选择支付方式"
  16. >
  17. <el-option label="支付宝支付" value="alipay_qr"></el-option>
  18. <el-option label="微信支付" value="wx_pub"></el-option>
  19. </el-select>
  20. </el-form-item>
  21. <el-table
  22. style="width: 100%; margin-bottom: 15px;"
  23. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  24. :data="tableList"
  25. >
  26. <el-table-column
  27. align="center"
  28. prop="platformServeName"
  29. label="产品名称"
  30. >
  31. </el-table-column>
  32. <el-table-column align="center" label="学员上限">
  33. <template slot-scope="scope">
  34. {{ scope.row.studentUpLimit | numberFormat }}人
  35. </template>
  36. </el-table-column>
  37. <el-table-column align="center" label="付费模式">
  38. <template slot-scope="scope">
  39. {{ scope.row.expiryUnit | memberEnumType }}
  40. </template>
  41. </el-table-column>
  42. <el-table-column align="center" prop="num" label="数量">
  43. </el-table-column>
  44. <el-table-column align="center" label="原价(元)">
  45. <template slot-scope="scope">
  46. {{ scope.row.rechargeAmount | hasMoneyFormat }}
  47. </template>
  48. </el-table-column>
  49. <el-table-column align="center" label="支付价格(元)">
  50. <template slot-scope="scope">
  51. <span style="color: red;">{{
  52. scope.row.value | hasMoneyFormat
  53. }}</span>
  54. </template>
  55. </el-table-column>
  56. </el-table>
  57. <el-form-item
  58. prop="checked"
  59. :rules="[
  60. { required: true, message: '请阅读并同意协议', trigger: 'change' }
  61. ]"
  62. >
  63. <el-checkbox v-model="payForm.checked" @change="onCheckChange">
  64. </el-checkbox>
  65. <span
  66. style="color: #606266; padding-left: 5px;cursor: pointer;"
  67. @click="onCheckBox"
  68. >我已阅读并同意</span
  69. >
  70. <span
  71. @click.stop="onLookContract"
  72. style="color: #01C1B5;cursor: pointer;"
  73. >《产品及服务协议》</span
  74. >
  75. </el-form-item>
  76. </el-form>
  77. <span slot="footer" class="dialog-footer">
  78. <el-button @click="$listeners.close()">取 消</el-button>
  79. <el-button @click="onMemberPay" type="primary">确 定</el-button>
  80. </span>
  81. <el-dialog
  82. title="查看协议"
  83. :visible.sync="lookVisible"
  84. width="415px"
  85. append-to-body
  86. >
  87. <previewProtocol
  88. @close="lookVisible = false"
  89. :look="true"
  90. :fileContent="fileContent"
  91. v-if="lookVisible"
  92. />
  93. </el-dialog>
  94. <el-dialog
  95. title="支付二维码"
  96. :visible.sync="payMentVisible"
  97. :before-close="onClose"
  98. v-if="payMentVisible"
  99. width="500px"
  100. append-to-body
  101. >
  102. <payment
  103. :tableList="tableList"
  104. :orderNo="orderNo"
  105. v-on="$listeners"
  106. :codeUrl="codeUrl"
  107. @close="onPaymentClose"
  108. />
  109. </el-dialog>
  110. </div>
  111. </template>
  112. <script>
  113. // import { recharge } from '../api'
  114. import { vaildStudentUrl } from "@/utils/validate";
  115. import payment from "@/views/productService/model/payment";
  116. import previewProtocol from "@/views/tenantSetting/model/previewProtocol";
  117. import { tenantInfoRePay, getContract } from "../api";
  118. import { getTenantId } from "@/utils/auth";
  119. export default {
  120. props: ["value", "tenantInfo"],
  121. components: { payment, previewProtocol },
  122. data() {
  123. return {
  124. payForm: {
  125. payType: null,
  126. checked: null
  127. },
  128. fileContent: null,
  129. lookVisible: false,
  130. pay_channel: null, //支付渠道
  131. selectStudentMoney: 0, // 选中学生金额
  132. payMentVisible: false,
  133. codeUrl: null,
  134. orderNo: null,
  135. tableList: []
  136. };
  137. },
  138. async mounted() {
  139. if (this.value) {
  140. const { contractPrice, originalPrice, ...res } = this.tenantInfo;
  141. this.tableList = [
  142. {
  143. ...res,
  144. num: this.value,
  145. rechargeAmount: this.value * originalPrice,
  146. value: this.value * contractPrice
  147. }
  148. ];
  149. }
  150. },
  151. methods: {
  152. onCheckChange() {
  153. if (!this.payForm.checked) {
  154. this.payForm.checked = null;
  155. }
  156. },
  157. onCheckBox() {
  158. if (this.payForm.checked) {
  159. this.payForm.checked = null;
  160. } else {
  161. this.payForm.checked = true;
  162. }
  163. },
  164. onMemberPay() {
  165. this.$refs.payForm.validate(async _ => {
  166. if (_) {
  167. try {
  168. console.log(this.value, "this.value");
  169. const res = await tenantInfoRePay({
  170. id: getTenantId(),
  171. val: this.value
  172. });
  173. // console.log(res)
  174. if (res.data.amount == 0 && res.data.orderNo) {
  175. this.$message.success("您已成功缴费");
  176. this.onPaymentClose(true);
  177. this.$listeners.getList();
  178. return;
  179. }
  180. const payForm = this.payForm;
  181. // 二维码页面, 唤起支付页面
  182. const {
  183. orderNo,
  184. sign,
  185. amount,
  186. orderBody,
  187. orderSubject,
  188. tenantId,
  189. returnUrl,
  190. notifyUrl
  191. } = res.data.payMap;
  192. this.orderNo = orderNo;
  193. this.codeUrl =
  194. vaildStudentUrl() +
  195. "/#/payCenter?orderNo=" +
  196. orderNo +
  197. "&sign=" +
  198. sign +
  199. "&amount=" +
  200. amount +
  201. "&payType=" +
  202. payForm.payType +
  203. "&orderBody=" +
  204. orderBody +
  205. "&orderSubject=" +
  206. orderSubject +
  207. "&platform=tenant" +
  208. "&tenantId=" +
  209. tenantId +
  210. "&returnUrl=" +
  211. returnUrl +
  212. "&notifyUrl=" +
  213. notifyUrl;
  214. console.log(this.codeUrl, "codeUrl");
  215. this.payMentVisible = true;
  216. } catch (e) {}
  217. }
  218. });
  219. },
  220. onClose(done) {
  221. this.onPaymentClose(false, done);
  222. },
  223. async onLookContract() {
  224. // 如果有协议则不需要重新请求
  225. if (!this.fileContent) {
  226. try {
  227. const tenantId = this.$helpers.tenantId;
  228. const res = await getContract({
  229. id: tenantId,
  230. type: 1,
  231. renewCount: this.value
  232. });
  233. this.fileContent = res.data;
  234. } catch (e) {}
  235. }
  236. this.lookVisible = true;
  237. },
  238. onPaymentClose(hideTip = false, callBack) {
  239. if (hideTip) {
  240. this.payMentVisible = false;
  241. this.$emit("close");
  242. return;
  243. }
  244. this.$confirm(`是否支付完成?`, "提示", {
  245. confirmButtonText: "已完成支付",
  246. cancelButtonText: "未完成支付",
  247. type: "warning"
  248. })
  249. .then(async res => {
  250. if (typeof callBack == "function") {
  251. callBack();
  252. }
  253. this.payMentVisible = false;
  254. })
  255. .catch(e => {
  256. if (typeof callBack == "function") {
  257. callBack();
  258. }
  259. this.payMentVisible = false;
  260. });
  261. }
  262. }
  263. };
  264. </script>
  265. <style lang="less" scoped>
  266. .chioseWrap {
  267. font-size: 16px;
  268. > p {
  269. font-weight: 500;
  270. padding-bottom: 15px;
  271. span {
  272. color: red;
  273. padding: 0 3px;
  274. }
  275. }
  276. }
  277. .dialog-footer {
  278. text-align: right;
  279. display: block;
  280. padding-top: 15px;
  281. }
  282. </style>