1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- import verification, {VerificationType} from '$utils/verification';
- import popup from "$utils/tool/popup";
- export default <LibMixins>{
- data(){
- return{
- moneyValue:'',
- disabled:false
- }
- },
- computed:{
- integral(){
- return (this.moneyValue || 0) * (this.$store.state.pay.payRatio || 0);
- }
- },
- methods:{
- allExChange(){
- if (this.disabled) return;
- let intMoney = parseInt(this.$store.getters.money);
- if (this.moneyValue !== intMoney) {
- this.moneyValue = intMoney;
- }
- },
- submitVerify(callback){
- if (!verification.trigger[VerificationType.empty](this.moneyValue)) {
- return popup.$toast('请输入兑换金额');
- } else if (this.moneyValue > this.$store.getters.money) {
- return popup.$toast('兑换金额不能大于余额');
- }
- return callback();
- },
- submit(obj){
- let value = this.moneyValue;
- let integral = this.integral;
- return this.$request({
- url:'user/exchange',
- data:{
- money: value
- },
- next:({status})=>{
- this.disabled = status;
- },
- token:true,
- message:true,
- failMessage:true
- }).then((data)=>{
- if (data.isSuccess) {
- this.user = {
- money: this.$store.getters.money - value,
- integral: this.$store.getters.integral + integral
- }
- // 执行更新 补救措施
- this.$store.dispatch('updateUserMoneyPromise');
- return this.close();
- }
- return obj.none();
- }).catch(obj.none);
- }
- }
- }
|