Browse Source

Merge branch 'master' of http://120.79.128.142:3000/904118851/xs

xy 1 năm trước cách đây
mục cha
commit
a1c58b5d4d
3 tập tin đã thay đổi với 117 bổ sung3 xóa
  1. 79 0
      xs-app/framework/util.ts
  2. 36 2
      xs-app/pages/bookstore/bookstore.vue
  3. 2 1
      xs-app/uni.scss

+ 79 - 0
xs-app/framework/util.ts

@@ -59,5 +59,84 @@ export class util {
 		}
 	}
 	
+	// Loadding
+	public static showLoading(title='加载中...',mask:boolean=false) {
+		uni.showLoading({
+			title:title,
+			mask:mask
+		})
+	}
+	
+	public static hideLoading() {
+		uni.hideLoading()
+	}
+	
+	// Toast
+	public static showInfoToast(title:string,duration=1500,mask=false) {
+		uni.showToast({
+			title:title,
+			icon:'none',
+			duration:duration,
+			mask:mask
+		})
+	}
+	
+	public static showSuccessToast(title:string,duration=1500,mask=false) {
+		uni.showToast({
+			title:title,
+			icon:'success',
+			duration:duration,
+			mask:mask
+		})
+	}
+	
+	public static showErrorToast(title:string,duration=1500,mask=false) {
+		uni.showToast({
+			title:title,
+			icon:'error',
+			duration:duration,
+			mask:mask
+		})
+	}
+	
+	// Modal
+	public static showModal(title:string, content:string, confirm_cb:Function=null, cancel_cb:Function=null, confirmText:string='确定', showCancel:boolean=true, cancelText:string='取消') {
+		uni.showModal({
+			title: title,
+			content: content,
+			confirmText: confirmText,
+			showCancel: showCancel,
+			cancelText: cancelText,
+			success: function (res) {
+				if (res.confirm) {
+					// console.log('用户点击确定')
+					confirm_cb && confirm_cb()
+				} else if (res.cancel) {
+					// console.log('用户点击取消')
+					cancel_cb && cancel_cb()
+				}
+			}
+		})
+	}
+	
+	public static showModalNoCancel(title:string, content:string, confirm_cb:Function=null, cancel_cb:Function=null, confirmText:string='确定'){
+		this.showModal(title,content,confirm_cb,cancel_cb,confirmText,false)
+	}
+	
+	// ActionSheet
+	public static showActionSheet(alertText:string, itemList:string[], confirm_cb:Function, cancel_cb:Function=null) {
+		uni.showActionSheet({
+			alertText:alertText,
+			itemList: itemList,
+			success: function (res) {
+				// console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
+				confirm_cb && confirm_cb(res.tapIndex)
+			},
+			fail: function (err) {
+				// console.log('showActionSheet err=',err.errMsg);
+				cancel_cb && cancel_cb()
+			}
+		});
+	}
 	
 }

+ 36 - 2
xs-app/pages/bookstore/bookstore.vue

@@ -1,9 +1,43 @@
 <template>
 	<view> 书城 </view>
+	<view style="display: flex; margin-top: 30px; height: 50px; font-size: 30px; background-color: red; justify-content: center; align-items: center;" 
+	@click="onClickTest"> 测试 </view>
 </template>
 
-<script>
+ <script >	 
+    import { util } from '../../framework/util';
+	export default {
+		data() {
+			return {
+			}
+		},
+		onLoad() {
+		},
+		methods: {
+			onClickTest() {
+				util.showLoading()
+				setTimeout(()=>{
+					util.hideLoading()
+				},1500)
+				
+				// util.showInfoToast('信息')
+				// util.showSuccessToast('成功')
+				// util.showErrorToast('失败')
+				
+				// util.showModal('标题',null,()=>{
+				// 	console.log('11111111')
+				// },null,'是吧')
+				
+				// util.showModalNoCancel('标题')
+				
+				// util.showActionSheet('你好', ['1','2','3'], (index)=>{
+				// 	console.log('确定index=',index)
+				// })
+			}
+		}
+	}
 </script>
 
-<style>
+<style lang="scss">
+	
 </style>

+ 2 - 1
xs-app/uni.scss

@@ -12,7 +12,8 @@
  * 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
  */
 
-/* 颜色变量 */
+/* 颜色变量 */
+$uni-theme-color: #2979ff;  //主色调
 
 /* 行为相关颜色 */
 $uni-color-primary: #007aff;