quick.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <view class="content">
  3. <view class="box padding-b-30">
  4. <view class="titlebox">
  5. <view class="titlename padding-l-30">
  6. 兑换文票
  7. </view>
  8. </view>
  9. <view class="row-box">
  10. <view class="title">兑入云票</view>
  11. <view class="row flex">
  12. <view class="flex name-box">
  13. <image class="nametip" src="../../static/icon/quick2.png" mode="scaleToFill"></image>
  14. <text class="padding-l-10 name">文票</text>
  15. </view>
  16. <input class="input margin-l-10" type="number" v-model="ticketnum" placeholder="请输入整数"
  17. placeholder-class="placeholder" />
  18. </view>
  19. </view>
  20. <view class="flex-center">
  21. <image class="tabquick" src="../../static/icon/quick0.png" mode="scaleToFill"></image>
  22. </view>
  23. <view class="row-box">
  24. <view class="title">兑出趣豆<text class="font-size-sm">(余额:{{userInfo.integral}})</text></view>
  25. <view class="row flex">
  26. <view class="flex name-box">
  27. <image class="nametip" src="../../static/icon/quick1.png" mode="scaleToFill"></image>
  28. <text class="padding-l-10 name">趣豆</text>
  29. </view>
  30. <view class="input margin-l-10" type="number" placeholder="0.00" placeholder-class="placeholder">
  31. {{ticketnum*ratio}}
  32. </view>
  33. </view>
  34. </view>
  35. <view class="row-box">
  36. <view class="title">输入账号</view>
  37. <view class="row flex">
  38. <view class="flex name-box">
  39. <image class="nametip" src="../../static/icon/quick3.png" mode="scaleToFill"></image>
  40. <text class="padding-l-10 name">文交所账号</text>
  41. </view>
  42. <input class="input margin-l-10" type="number" v-model="card" placeholder="请输入文交所账号"
  43. placeholder-class="placeholder" />
  44. </view>
  45. </view>
  46. <button class="add-btn up" :class="{ action: loding }" @click="!loding ? confirm() : ''">确认兑换</button>
  47. </view>
  48. <navigator url="./quickList">
  49. <view class="box margin-t-30">
  50. <view class="titlebox flex">
  51. <view class="flex-start">
  52. <image class="nametip" src="../../static/icon/quick4.png" mode="scaleToFill"></image>
  53. <text class="padding-l-10">兑换记录</text>
  54. </view>
  55. <image class="nextTip" src="../../static/img/back.png" mode="scaleToFill"></image>
  56. </view>
  57. </view>
  58. </navigator>
  59. <view class="echart-box"><l-echart ref="chart" @finished="init"></l-echart></view>
  60. </view>
  61. </template>
  62. <script>
  63. import {
  64. getUserInfo,
  65. admintrade,
  66. trade
  67. } from '@/api/user.js';
  68. import {
  69. getTicket,
  70. getExchange
  71. } from '@/api/quick.js';
  72. import {
  73. mapMutations,
  74. mapState
  75. } from 'vuex';
  76. export default {
  77. data() {
  78. return {
  79. ticketnum: '', //兑换文票数
  80. integral: '', //兑换所需要的积分数
  81. card: '', //转账卡号
  82. ratio: 1, //兑换比例
  83. loding: false,
  84. type: '1'
  85. };
  86. },
  87. onLoad(options) {
  88. // this.dataUp();
  89. // 加载文票比例
  90. this.getTicket();
  91. },
  92. computed: {
  93. ...mapState('user', ['userInfo'])
  94. },
  95. methods: {
  96. ...mapMutations('user', ['setUserInfo', 'login']),
  97. // 更新数据
  98. dataUp() {
  99. let obj = this;
  100. getUserInfo({})
  101. .then(e => {
  102. obj.login();
  103. // 保存返回用户数据
  104. obj.setUserInfo(e.data);
  105. })
  106. .catch(e => {
  107. console.log(e);
  108. });
  109. },
  110. getTicket() {
  111. getTicket().then(
  112. (res) => {
  113. console.log(res);
  114. if (res.data.v.CurPrice != 0 && res.data.integral_price != 0) {
  115. this.ratio = +(res.data.v.CurPrice / res.data.integral_price).toFixed(2);
  116. } else {
  117. this.loding = true;
  118. uni.showModal({
  119. title: '提示',
  120. content: '当前兑换暂未开放',
  121. showCancel: false,
  122. });
  123. }
  124. }
  125. ).catch(
  126. (res) => {
  127. console.log(res);
  128. }
  129. )
  130. },
  131. // 提交
  132. confirm() {
  133. let obj = this;
  134. obj.loding = true;
  135. if (!this.ticketnum) {
  136. uni.showToast({
  137. title: '请输入兑换数量',
  138. icon: 'error'
  139. });
  140. return
  141. }
  142. if (this.ticketnum.indexOf('.') > -1) {
  143. uni.showToast({
  144. title: '请输入整数',
  145. icon: 'error'
  146. });
  147. return
  148. }
  149. // if(this.ticketnum*this.ratio>this.userInfo.integral){
  150. // uni.showToast({
  151. // title: '趣豆不足无法兑换',
  152. // icon:'error'
  153. // });
  154. // return
  155. // }
  156. if (!this.card) {
  157. uni.showToast({
  158. title: '请输入社交账号',
  159. icon: 'error'
  160. });
  161. return
  162. }
  163. let data = {
  164. account: obj.card, //账号
  165. extract_ticket: obj.ticketnum, //数量
  166. };
  167. uni.showModal({
  168. title: '提示',
  169. content: `本人委托王伟将本人所持有的 53年18K一分券送至中藏仓储有限公司进行鉴定托管,在整个鉴定托管过程中,该委托人的一切行为,均代表我本人,与本人的行为具有同等法律效力,我本人将承担该委托人行为的全部法律后果和责任。`,
  170. cancelText: '不同意',
  171. confirmText: '我同意',
  172. success: res => {
  173. if (res.confirm) {
  174. getExchange(data)
  175. .then(e => {
  176. // 允许按钮点击
  177. obj.loding = false;
  178. // 初始化提现金额
  179. obj.ticketnum = '';
  180. uni.showToast({
  181. title: e.msg,
  182. duration: 2000,
  183. position: 'top'
  184. });
  185. obj.dataUp();
  186. })
  187. .catch(e => {
  188. obj.$api.msg(e.msg);
  189. obj.loding = false;
  190. });
  191. }
  192. },
  193. fail: (err) => {
  194. console.log(err);
  195. }
  196. });
  197. }
  198. }
  199. };
  200. </script>
  201. <style lang="scss">
  202. page {
  203. height: 100%;
  204. }
  205. .content {
  206. padding-top: 30rpx;
  207. .box {
  208. background-color: #FFF;
  209. line-height: 1;
  210. .titlebox {
  211. padding: 30rpx;
  212. font-weight: bold;
  213. font-size: $font-lg;
  214. border-bottom: 1px solid $border-color-base;
  215. .titlename {
  216. border-left: 2px solid $color-red ;
  217. }
  218. .nextTip {
  219. width: 20rpx;
  220. height: 40rpx;
  221. }
  222. }
  223. .tabquick {
  224. width: 70rpx;
  225. height: 70rpx;
  226. }
  227. .nametip {
  228. width: 40rpx;
  229. height: 40rpx;
  230. }
  231. .row-box {
  232. padding: 30rpx;
  233. .title {
  234. font-size: $font-sm;
  235. color: $font-color-light;
  236. padding-bottom: 20rpx;
  237. }
  238. .row {
  239. position: relative;
  240. .name-box {
  241. font-weight: bold;
  242. font-size: $font-base;
  243. width: 220rpx;
  244. .name {
  245. flex-grow: 1;
  246. border-right: 2px solid $font-color-disabled;
  247. margin-right: 10rpx;
  248. }
  249. }
  250. .input {
  251. flex: 1;
  252. font-size: 30rpx;
  253. height: 60rpx;
  254. line-height: 60rpx;
  255. color: $font-color-dark;
  256. border-bottom: 1px solid $border-color-light;
  257. }
  258. }
  259. }
  260. }
  261. }
  262. .add-btn {
  263. height: 80rpx;
  264. border-radius: 10rpx;
  265. margin: 0 50rpx;
  266. margin-top: 30rpx;
  267. color: #FFF;
  268. background-color: $uni-color-error ;
  269. &.action {
  270. background-color: $border-color-light ;
  271. }
  272. }
  273. </style>