Browse Source

no message

laosan2382995021@163.com 3 years ago
parent
commit
00eb30a42d

+ 8 - 0
uni-shop/layout/layout-shop-screen/props.js

@@ -0,0 +1,8 @@
+export default {
+
+    dateBuy:{
+        type:Number,
+        default:0
+    }
+
+}

+ 43 - 0
uni-shop/pages/consumption-record/consumption-record.vue

@@ -0,0 +1,43 @@
+<template>
+  <v-header title="余额记录">
+    <flat-list
+        @changeData="flatChangeData"
+        background="#fff"
+        @fetch="fetch"
+        :ref="base_flat_id"
+        :pageSize="15"
+    >
+      <view class="recharge-container">
+        <view class="recharge-item row aCenter"
+          v-for="(item,index) in base_flat_data.data"
+              :key="index"
+        >
+          <view class="flex-all-1 overflow">
+            <view class="line-1 recharge-item-title"
+            >{{ item.memo }}</view>
+            <view class="line-1 recharge-item-time" >{{item.createtime}}</view>
+          </view>
+          <view class="recharge-item-price" >¥{{item.money}}</view>
+        </view>
+      </view>
+    </flat-list>
+  </v-header>
+</template>
+
+<script>
+import vHeader from '@/components/v-header/main';
+import FlatList from '@/components/flat-list/src/main';
+import mixins from './mixins';
+export default {
+  name: "consumption-record",
+  mixins,
+  components:{
+    vHeader,
+    FlatList
+  }
+}
+</script>
+
+<style scoped src="./style.scss" lang="scss">
+
+</style>

+ 21 - 0
uni-shop/pages/consumption-record/mixins/handle.js

@@ -0,0 +1,21 @@
+import dateParse from '@/utils/tool/date';
+export default {
+
+    methods:{
+
+        fetch(obj){
+            return this.$request({
+                url:'user/getMoneyLog',
+                token:true,
+                page:obj
+            }).then((data)=>{
+                return obj.success((data.data||[]).map((item)=>{
+                    item.createtime = dateParse(item.createtime,'YYYY-MM-DD hh:mm');
+                    return item;
+                }));
+            }).catch(obj.fail);
+        }
+
+    }
+
+}

+ 5 - 0
uni-shop/pages/consumption-record/mixins/index.js

@@ -0,0 +1,5 @@
+import flatListMixins from '@/components/flat-list/export';
+import handle from './handle';
+import globalMixins from '@/mixins/global';
+
+export default [globalMixins,handle,flatListMixins];

+ 32 - 0
uni-shop/pages/consumption-record/style.scss

@@ -0,0 +1,32 @@
+/* 容器 */
+.recharge-container{
+  padding: 0 30upx;
+}
+/* 容器 */
+/* 视图 */
+.recharge-item{
+  height: 130upx;
+
+  border-bottom: 1upx solid #F1F1F1;
+}
+.recharge-item:last-of-type{
+  border-bottom: none;
+}
+.recharge-item-title{
+  font-size: 30upx;
+  line-height: 36upx;
+  color: #333;
+}
+.recharge-item-time{
+  color: #999;
+  font-size: 26upx;
+  line-height: 30upx;
+  margin-top: 12upx;
+}
+.recharge-item-price{
+  font-size: 28upx;
+  line-height: 34upx;
+  color: #333;
+  margin-left: 20upx;
+}
+/* 视图 */

+ 116 - 0
uni-shop/pages/order-detail/mixins/payEnd.js

@@ -0,0 +1,116 @@
+import order from '../../../utils/controls/order';
+import notice from '@/utils/notice/index';
+export default {
+
+	data:function () {
+		return {
+			payStatus:{
+				msg:''
+			}
+		}
+	},
+
+	methods:{
+
+		installPayEnd(item){
+			if (item.have_paid === 0 && item.time && item.duetime) {
+				let msg = this.setCountDown();
+				if (msg) {
+					this.payStatus.msg = msg;
+				} else {
+					this.setStatusCancel();
+				}
+			}
+		},
+
+		/* 设置倒计时 */
+		setCountDown:function () {
+
+			if (this.endTime === undefined) {
+				// this.data.order.createdtime +
+				this.endTime = this.item.orderInfo.duetime;
+				this.startTime = parseInt(new Date().getTime()/1000);
+			}
+			let diff = this.getTimeDiff();
+
+			if (diff > 0) {
+				this.runCountDown();
+				return this.getCountDownText(diff);
+			} else {
+				return false;
+			}
+
+		},
+
+		getTimeDiff(){
+			let nowTime = parseInt(new Date().getTime()/1000);
+
+			let diff = nowTime - this.startTime;
+
+			diff = this.endTime - diff - this.item.orderInfo.time;
+
+
+			return diff;
+
+		},
+
+		/* 开启倒计时 */
+		runCountDown:function(){
+
+			// 一分钟触发一次
+			this.time = setTimeout(()=>{
+
+				let diff = this.getTimeDiff();
+				if (diff <= 0) {
+					clearTimeout(this.time);
+					return this.setStatusCancel();
+				} else {
+					this.payStatus.msg = this.getCountDownText(diff);
+					return this.runCountDown();
+				}
+
+			},1000);
+
+		},
+
+		// 设置状态已取消
+		setStatusCancel:function(){
+
+			this.changeStatus(order.createdUpdateObj('cancel',this.item.orderInfo,'','已取消'));
+
+			// 执行调用取消接口
+			return this.$request({
+				url:'order/apiCancelOrder',
+				data:{
+					order_id: this.item.orderInfo.id
+				},
+				token:true,
+				login:false
+			}).then(()=>{
+				// 设置视图状态为已取消
+				notice.trigger('order',order.createdUpdateObj('cancel',this.item.orderInfo,'','已取消'));
+			});
+		},
+
+		getCountDownText:function (diff) {
+
+			let h = parseInt(diff / 60 / 60 % 60);
+			h = h <10?'0'+h:h;
+
+			let m = parseInt(diff / 60 % 60);
+			m = m <10?'0'+m:m;
+
+			let s = parseInt(diff % 60);
+			s = s <10?'0'+s:s;
+
+			return '剩'+h+'小时'+m+'分'+s+'秒自动关闭';
+		},
+	},
+
+	beforeDestroy:function () {
+		clearTimeout(this.time);
+	}
+
+
+
+}

BIN
uni-shop/static/images/code.png


BIN
uni-shop/static/images/control/consumption.png


BIN
uni-shop/static/images/delete.png


+ 21 - 0
uni-shop/store/modules/car.js

@@ -0,0 +1,21 @@
+
+import car from '../../utils/controls/car';
+
+export default {
+    state: {
+        carNumber:0
+    },
+
+    mutations: {
+        setNumberFormat(state,number){
+            if (state.carNumber !== number) {
+                state.carNumber = number;
+            }
+        }
+    },
+    actions:{
+        updateCarPromise(state,update=false){
+            return car.getCartNumber(update);
+        }
+    }
+}

+ 127 - 0
uni-shop/utils/controls/car.js

@@ -0,0 +1,127 @@
+import request from '../../utils/request/index';
+
+import store from '../../store/index';
+
+export default {
+
+	// 当前是否处于发起请求
+	status: false,
+
+	// 本次请求的 唯一标示
+	requestUnique: 0,
+
+	// 购物数量 当前统计
+	number: 0,
+
+	numberFormat: '',
+
+	getCartNumber:function (must) {
+
+		if (!this.status || must) {
+
+			let requestUnique = this.getUnique();
+
+			this.requestUnique = requestUnique;
+
+		    return new Promise( (resolve, reject)=> {
+
+				request({
+					url:'product/getCartNum',
+					token:true,
+					login:false,
+					next:(status)=>{
+						this.status = status;
+					}
+				}).then((data)=>{
+
+					if (requestUnique === this.requestUnique) {
+
+						if ( data.isSuccess) {
+							this.setCartNumber(data.data);
+
+							return resolve(this.number);
+						} else {
+							return reject({
+								data: data,
+								status: data.status,
+								msg:data.msg
+							});
+						}
+
+					} else {
+						return reject({
+							data: data,
+							status: 0,
+							msg:'invalid request'
+						});
+					}
+
+				}).catch((fail)=>{
+					return reject({
+						status: 4,
+						msg: fail
+					})
+				});
+
+			});
+
+		}
+
+	},
+
+	setCartNumber:function(number){
+
+		if (number !== this.number) {
+
+			this.number = number;
+
+			if (number <= 0) {
+				this.numberFormat  = '';
+			} else {
+				this.numberFormat = number >99?'99+': String(number);
+			}
+
+			// 更新
+			store.commit('setNumberFormat',this.number);
+
+			// wx.tab
+			return this.saveTabBarBadge();
+
+		}
+
+
+	},
+
+	checkSet:function(){
+		if (this.setFail) {
+			return this.saveTabBarBadge();
+		}
+
+	},
+
+	saveTabBarBadge:function(){
+
+		if (this.number > 0) {
+
+			return uni.setTabBarBadge({
+				index: 2,
+				text: this.numberFormat,
+				fail:()=>{
+					this.setFail = true;
+				}
+			})
+		} else {
+			return wx.removeTabBarBadge({
+				index: 2,
+				fail:(res) =>{
+					this.setFail = true;
+				}
+			});
+		}
+	},
+
+	getUnique:function () {
+		return new Date().getTime();
+	}
+
+}