integral_sc.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <template>
  2. <view>
  3. <uni-nav-bar :border="false" statusBar left-icon="left" @clickLeft="utils.navigateBack()" @clickRight="tapOpenLog" fixed title="趣豆转账">
  4. <view style="color: #ef4034;" slot="right">
  5. 转账记录
  6. </view>
  7. </uni-nav-bar>
  8. <view style="height: 10px;"></view>
  9. <view class="topinfo fx-h fx-bc fx-ac">
  10. <view class="count">{{ user.integral || 0 }}</view>
  11. <view class="text">当前可用(趣豆)</view>
  12. </view>
  13. <view style="height: 10px;"></view>
  14. <view class="info-line">
  15. <view class="il-top">
  16. <text>文票账号</text>
  17. </view>
  18. <view class="il-bot">
  19. <input placeholder="文票账号" type="text" v-model="number" />
  20. </view>
  21. </view>
  22. <view class="info-line">
  23. <view class="il-top">
  24. <text>文票兑换(比例)</text>
  25. </view>
  26. <view class="fx-r">
  27. <view class="il-bot" v-if="data.price == -1">
  28. 加载中..
  29. </view>
  30. <view class="il-bot" v-else>
  31. {{ data.price }}趣豆/张
  32. </view>
  33. <view class="fx-g1"></view>
  34. <view class="il-bot" v-if="data.price > 0" style="font-size: 14px;">(可兑换{{ getMaxCount() }}张)</view>
  35. </view>
  36. </view>
  37. <view class="info-line">
  38. <view class="il-top">
  39. <text>兑换张数</text>
  40. </view>
  41. <view class="il-code">
  42. <view class="etb-left">
  43. <input placeholder="请输入兑换张数" placeholder-class="placeholder-class" v-model="num" />
  44. </view>
  45. </view>
  46. </view>
  47. <view class="info-line">
  48. <view class="update-btn" @click="tapSubmit">
  49. <text>确认兑换</text>
  50. </view>
  51. <view style="height: 10px;"></view>
  52. </view>
  53. <PayDialog ref="payDialog" @getPassword="getPassword"></PayDialog>
  54. </view>
  55. </template>
  56. <script>
  57. import {
  58. mapState,
  59. mapMutations
  60. } from 'vuex';
  61. import PayDialog from "@/components/ui-pay/payDialog.vue";
  62. export default {
  63. computed: mapState(['user','sysData']),
  64. components:{
  65. PayDialog
  66. },
  67. data() {
  68. return {
  69. number : "",
  70. num:'',
  71. type : "id",
  72. new_mobile : "",
  73. uid : "",
  74. sendname : "",
  75. data : {
  76. price : -1
  77. }
  78. }
  79. },
  80. onLoad(options) {
  81. this.checkUserLogin({page:this,isLogion:false,fn:this.initView});
  82. },
  83. methods: {
  84. ...mapMutations(['checkUserLogin']),
  85. initView:function(){
  86. this
  87. .request
  88. .get("integralTicketInit")
  89. .then(res=>{
  90. if(res.code == 200) {
  91. this.data = res.data;
  92. } else {
  93. this.utils.Tip(res.msg);
  94. }
  95. });
  96. },
  97. tapGetMobile:function(ev){
  98. let mobile = ev.detail.value;
  99. if(!this.utils.isPoneAvailable(mobile)) {
  100. this.sendname = '';
  101. return;
  102. }
  103. this
  104. .request
  105. .post("userCkUserName",{mobile : mobile,type : 2})
  106. .then(res => {
  107. if(res.code == 200) {
  108. this.sendname = res.data.name;
  109. } else {
  110. //this.utils.Tip(res.msg);
  111. }
  112. });
  113. },
  114. getMaxCount:function(){
  115. let value = parseInt(this.user.integral / this.data.price);
  116. return value;
  117. },
  118. tapOpenLog:function(){
  119. uni.navigateTo({ url:"integral_gift_log"});
  120. },
  121. /**
  122. * 预计扣除
  123. */
  124. getKc:function(){
  125. if(isNaN(this.num)) return "0.00";
  126. let val = this.utils.returnFloat(this.num * (this.data.lv / 100));
  127. return val;
  128. },
  129. /**
  130. * 全部
  131. */
  132. allMoney:function(){
  133. if(this.user.integral <= 0) return 0;
  134. let val = this.utils.returnFloat(this.user.integral * (this.data.lv / 100));
  135. return this.user.integral - parseFloat(val);
  136. },
  137. /**
  138. * 提交数据
  139. */
  140. tapSubmit:function(){
  141. if(this.data.price < 0) {
  142. this.utils.Tip("兑换比例未加载完毕,请稍等!");
  143. return;
  144. }
  145. let maxValue = parseInt(this.user.integral / this.data.price);
  146. if(this.number == '' ){
  147. this.utils.Tip("请输入文票账号");
  148. return;
  149. }
  150. if(this.num <= 0 || this.num == ''){
  151. this.utils.Tip("请输入兑换张数");
  152. return;
  153. }
  154. //判断兑换数量
  155. if(parseInt(this.num) > maxValue){
  156. this.utils.Tip("兑换张数已经超过了");
  157. return;
  158. }
  159. this.$refs['payDialog'].show();
  160. },
  161. getPassword : function(val){
  162. var password = val.password;
  163. this.utils.loadIng("提交中..");
  164. this
  165. .request
  166. .post("integralTicket",
  167. {
  168. new_password : password,
  169. number : this.number,
  170. num : this.num
  171. })
  172. .then(res=>{
  173. uni.hideLoading();
  174. if(res.code == 200) {
  175. this.utils.Tip(res.msg);
  176. setTimeout(function(){ uni.navigateBack();},1000);
  177. }else{
  178. this.utils.Tip(res.msg);
  179. this.$refs['payDialog'].cleanNum();
  180. }
  181. }).catch(function(){
  182. uni.hideLoading();
  183. this.utils.Tip("网络错误,请稍后尝试");
  184. });
  185. }
  186. },
  187. }
  188. </script>
  189. <style>
  190. page {
  191. background: #F5F5F5;
  192. }
  193. #box {
  194. padding-top: 90px;
  195. z-index: -1;
  196. }
  197. .topinfo{
  198. background: #fff;
  199. padding: 40rpx 0;
  200. .count{
  201. background-size: 100%;
  202. font-size: 24px;
  203. color: #303133;
  204. font-weight: 700;
  205. background-repeat: no-repeat;
  206. background-position: 50%;
  207. }
  208. .text{
  209. color: #909399;
  210. font-size: 18px;
  211. }
  212. }
  213. .info-line {
  214. min-height: 80px;
  215. padding: 0 15px;
  216. background-color: #fff;
  217. border-top: 1px #f5f5f5 solid;
  218. }
  219. .il-top {
  220. color: #ef4034;
  221. font-size: 14px;
  222. margin-top: 10px;
  223. }
  224. .il-bot {
  225. margin-top: 10px;
  226. position: relative;
  227. }
  228. .il-bot input {
  229. width: 100%;
  230. height: 100%;
  231. }
  232. .il-bot .name{position: absolute;right: 10px;top: 0px;}
  233. .update-btn {
  234. width: 90%;
  235. height: 40px;
  236. text-align: center;
  237. line-height: 40px;
  238. margin: 30px auto;
  239. background: #ef4034;
  240. color: #fff;
  241. border-radius: 100px;
  242. font-size: 16px;
  243. }
  244. .il-code {
  245. display: flex;
  246. align-items: center;
  247. margin-top: 10px;
  248. }
  249. .il-code input {
  250. width: 50%;
  251. height: 100%;
  252. font-size: 13px;
  253. }
  254. .ilc-btn {
  255. width: 90px;
  256. height: 30px;
  257. text-align: center;
  258. line-height: 30px;
  259. margin-left: auto;
  260. font-size: 12px;
  261. background: #ef4034;
  262. color: #fff;
  263. border-radius: 100px;
  264. }
  265. .ilc-no-show {
  266. width: 90px;
  267. height: 30px;
  268. text-align: center;
  269. line-height: 30px;
  270. margin-left: auto;
  271. font-size: 12px;
  272. background: #eee;
  273. color: #999;
  274. border-radius: 100px;
  275. }
  276. .etb-left{width:80%;height:100%}
  277. .placeholder-class{color:#7e7e7e;font-size:13px;font-weight:400}
  278. .etb-left input{width:100%;height:100%;color:#484747;font-size:22px;font-weight:600}
  279. .etb-right{margin-left:auto;color:#2d2438;font-size:13px}
  280. .tip{font-size: 14px;padding: 10px 0;color: #ef4034;}
  281. .tip-info{padding: 5px 0;}
  282. .tip-info .label{color: #000;font-weight: bold;}
  283. .tip-info .money{color: orangered;}
  284. </style>