<!doctype html>
<html>javascript
<head>
<meta charset="UTF-8">
<title>直播生活商家端-訂單大廳</title>
<script src="../../js/flexible.js"></script>
<script src="../../js/mui.min.js"></script>
<link rel="stylesheet" href="../../fonts/iconfont.css" />
<link rel="stylesheet" href="../../css/mui.min.css" />
<link rel="stylesheet" href="../../css/init.css" />
<link rel="stylesheet" type="text/css" href="../../css/gz_css.css" />css
</head>html
<body style="background-color: #f7f7f7">
<header class="mui-bar mui-bar-nav gz_bar">
<h1 class="mui-title">訂單大廳</h1>
</header>vue
<div class="mui-content gz_order_index" id="order_index">
<div class="gz_box">
<ul class="mui-table-view gz_order_ul">
<li class="mui-table-view-cell mui-media gz_order_li gz_xiangqing" v-for="val in order" :data-id="val.order_id">
<a href="javascript:;" class="gz_order_li_a">
<div class="gz_order_top">
<span class="gz_order_top_left">訂單號:<em>{{val.order_sn}}</em></span>
<span class="gz_order_top_right">{{val.add_time}}</span>
</div>
<div class="gz_order_index_li_body">
<div class="gz_order_body_1">
<h1><em>{{val.order_id}} {{val.consignee}}</em>{{val.mobile}}</h1>java
</div>
<div class="gz_order_body_2">
<h1><span>12:00</span><span>前送達</span></h1>
<ul>
<li v-for="val2 in val.goods_list">/*循環套循環*/
<h3>{{val2.goods_name}}</h3>
<h4>x{{val2.goods_num}}</h4>
<h5>¥{{val2.goods_price}}</h5>
</li>
</ul>jquery
</div>web
<div class="gz_order_body_3">
<button type="button" class="mui-btn mui-btn-block mui-btn-primary gz_jiedan">接單</button>
</div>
</div>
</a>
</li>ajax
</ul>
</div>
</div>
<div class="gz_button_box_show"></div>json
<script src="../../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>服務器
<script src="../../js/Vue.js"></script>
<script src="../../js/common.js"></script>
<script type="text/javascript" charset="utf-8">
mui.init({});//初始化
var order_index_vue = new Vue({
el: '#order_index',
data: {
order: [] //order
},
methods: {
get_shangjia_info: function() {
var that = this;
mui.ajax(site_url + '/Home/Business/getOrderList', {
data: {
token: plus.storage.getItem('token'),
type: 0
},
dataType: 'json', //服務器返回json格式數據
type: 'post', //HTTP請求類型
timeout: 10000, //超時時間設置爲10秒,超時報錯;
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
success: function(data) {
console.log(JSON.stringify(data));
if(data.status == 1) {//狀態爲1,正常
that.order = data.data,
console.log(JSON.stringify(that.order))
} else {
mui.toast(data.msg)
}
},
error: function(xhr, type, errorThrown) {
console.log('網絡錯誤');
}
});
}
}
})
mui.plusReady(function() {
order_index_vue.get_shangjia_info();
});
$(".gz_order_ul").on("click", ".gz_order_li", function(e) {
console.log(111);
e.stopPropagation();
var id = this.getAttribute("data-id");//獲取產品的data-id
// console.log(id);
// alert(id);
mui.openWindow({
url: "../order/order_details.html",
id: "order_details",
extras:{
order_index_id:id
},
})
})
$(".gz_order_ul").on("click", ".gz_jiedan", function(e) {
console.log(1222);
e.stopPropagation(); //阻止冒泡,列表裏面有按鈕要點擊的時候
var jiedan = plus.webview.currentWebview().selfid; //經過id獲取頁面
var botton = plus.webview.getWebviewById(jiedan);
mui.fire(botton, "jiedan", ''); //自定義事件
})
</script>
</body>
</html>
總結:
套數據步驟:
1,套數據時,首先看看是否引入了vue.js和域名;
2,new一個vue
3,vue最外面的父級放上id
4,模擬數據。data:{假數據},讓頁面展現出來
5,調接口,讓頁面變活
6,列表頁,數據空作判斷,數據空提示暫無數據,下拉刷新,上拉加載
注意事項:
1,使用vue時,列表是須要循環出來的, v-for="val in order",{{val.order_sn}}
2,使用ajax時候不要忘記調用
3,使用class,id名,不要忘記.,#
4,事件綁定失敗,點擊事件不觸發:
1.找到事件的方法,裏面console一下,沒有在外面在console
2.頁面有沒有報錯
3.看綁定事件,名字對不對。class少沒有,{}對不對,逗號,冒號,分號,類名點,id#
4.報錯...is not a function 找到了報錯頁面,是否報錯,檢查那句報錯了,單詞跟上面是否對起來了