buy.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <template>
  2. <div class="app-container">
  3. <div class="counts">
  4. <div class="title">通话统计</div>
  5. <div class="items">
  6. <div class="item">
  7. <div class="name">
  8. 公司余额
  9. </div>
  10. <div class="count green">
  11. <span >{{company.money}}</span>元
  12. </div>
  13. </div>
  14. <div class="item">
  15. <div class="name">
  16. 坐席数量
  17. </div>
  18. <div class="count green">
  19. <span >{{company.voiceCallerNumber}}</span>个
  20. </div>
  21. </div>
  22. <div class="item">
  23. <div class="name">
  24. 剩余通话分钟数
  25. </div>
  26. <div class="count red">
  27. <span >{{voice.times}}</span>分
  28. </div>
  29. </div>
  30. <div class="item">
  31. <div class="name">
  32. 累计通话分钟数
  33. </div>
  34. <div class="count green">
  35. <span >{{voice.totalTimes}}</span>分
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. <el-tabs v-model="activeName" >
  41. <el-tab-pane label="套餐购买" name="first">
  42. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  43. <el-form-item label="套餐" prop="packageId" >
  44. <div class="package">
  45. <div @click="selectItem(item)" v-for="(item,index) in packages">
  46. <el-card shadow="hover" :class="form.packageId==item.packageId?'item active':'item'" >
  47. {{item.packageName}}
  48. </el-card>
  49. </div>
  50. </div>
  51. </el-form-item>
  52. <div class="footer-btn">
  53. <el-button type="primary" @click="submitForm">立即购买</el-button>
  54. </div>
  55. </el-form>
  56. </el-tab-pane>
  57. </el-tabs>
  58. </div>
  59. </template>
  60. <script>
  61. import { getVoicePackagelist, buy} from "@/api/company/companyVoicePackageOrder";
  62. import { getCompanyInfo,getCompanyVoice } from "@/api/company/company";
  63. export default {
  64. name: "CompanyRecharge",
  65. data() {
  66. return {
  67. company:null,
  68. activeName:"first",
  69. voice:null,
  70. packages:[],
  71. package:{},
  72. orderNo:"",
  73. money:0,
  74. // 表单参数
  75. form: {
  76. packageId:null,
  77. },
  78. // 表单校验
  79. rules: {
  80. packageId: [
  81. { required: true, message: "套餐不能为空", trigger: "blur" },
  82. ],
  83. }
  84. };
  85. },
  86. created() {
  87. this.getCompanyInfo();
  88. this.getCompanyVoice();
  89. this.getVoicePackagelist();
  90. },
  91. methods: {
  92. selectItem(item){
  93. this.form.packageId=item.packageId;
  94. console.log(this.form.packageId)
  95. },
  96. getCompanyVoice(){
  97. getCompanyVoice().then(response => {
  98. this.voice = response.data;
  99. });
  100. },
  101. getCompanyInfo(){
  102. getCompanyInfo().then(response => {
  103. this.company = response.data;
  104. });
  105. },
  106. getVoicePackagelist() {
  107. getVoicePackagelist().then(response => {
  108. this.packages = response.data;
  109. });
  110. },
  111. /** 提交按钮 */
  112. submitForm() {
  113. var that=this;
  114. this.$refs["form"].validate(valid => {
  115. if (valid) {
  116. buy(this.form).then(response => {
  117. if (response.code === 200) {
  118. this.msgSuccess("充值成功");
  119. this.getCompanyInfo();
  120. this.getCompanyVoice();
  121. }
  122. });
  123. }
  124. });
  125. },
  126. }
  127. };
  128. </script>
  129. <style lang="scss" scoped>
  130. .package{
  131. display: flex;
  132. .item{
  133. width:200px;
  134. margin: 0px 10px;
  135. cursor: pointer;
  136. }
  137. .active{
  138. border: 1px solid #13c2c2;;
  139. }
  140. }
  141. .el-radio{
  142. margin-right: 0px;
  143. }
  144. .radio{
  145. display: flex;
  146. align-items: center;
  147. }
  148. .radio-item{
  149. padding-right:15px;
  150. .radio-img{
  151. margin-right: 10px;
  152. }
  153. .el-radio{
  154. display: flex;
  155. align-items: center;
  156. .el-radio__label{
  157. display: flex;
  158. align-items: center;
  159. }
  160. }
  161. }
  162. .footer-btn{
  163. padding-top: 30px;
  164. border-top: 1px solid #eee;
  165. display: flex;
  166. justify-content: flex-end;
  167. }
  168. .pay-dialog-cont{
  169. padding: 5px 0 50px;
  170. display: flex;
  171. flex-direction: column;
  172. align-items: center;
  173. .price{
  174. display: flex;
  175. align-items: flex-end;
  176. .label{
  177. font-size: 14px;
  178. color: #666666;
  179. margin-right: 10px;
  180. line-height: 20px;
  181. }
  182. .unit{
  183. font-size: 16px;
  184. font-weight: bold;
  185. color: #FF6633;
  186. margin-right: 5px;
  187. line-height: 20px;
  188. }
  189. .num{
  190. font-size: 24px;
  191. font-weight: bold;
  192. color: #FF6633;
  193. }
  194. }
  195. .order-sn{
  196. font-size: 14px;
  197. color: #666666;
  198. line-height: 1;
  199. margin-top: 20px;
  200. }
  201. .code-box{
  202. width: 200px;
  203. height: 200px;
  204. margin-top: 40px;
  205. img{
  206. width: 100%;
  207. height: 100%;
  208. object-fit: cover;
  209. }
  210. }
  211. .tip-box{
  212. margin-top: 30px;
  213. display: flex;
  214. align-items: center;
  215. flex-direction: column;
  216. font-size: 14px;
  217. color: #333333;
  218. line-height: 22px;
  219. .orange{
  220. color: #FF6633;
  221. }
  222. }
  223. }
  224. .counts{
  225. padding: 15px;
  226. border: 1px solid #ddd;
  227. display: flex;
  228. flex-direction: column;
  229. align-items: flex-start;
  230. justify-content: center;
  231. .title{
  232. margin-left: 30px;
  233. margin-bottom: 20px;
  234. font-size: 18px;
  235. font-weight: bold;
  236. }
  237. .items{
  238. display: flex;
  239. align-items: flex-start;
  240. justify-content: center;
  241. .item{
  242. padding: 0px 30px;
  243. border-right: 1px solid #eee;
  244. &:last-child{
  245. border-right: none;
  246. }
  247. .name{
  248. font-size: 14px;
  249. font-weight: normal;
  250. margin-bottom: 5px;
  251. }
  252. .count{
  253. font-size: 14px;
  254. font-weight: normal;
  255. }
  256. .red{
  257. color: red;
  258. }
  259. .green{
  260. color: #13c2c2;
  261. }
  262. }
  263. }
  264. }
  265. </style>