数据绑定 变量发生变化,页面上的不动态修改

为什么  store  发生改变  页面上的值不发生改变  
 
<template>
<ui-page top="0">
<!-- 头部 -->
<ui-nav-bar slot="nav-bar">
<ui-row height="46" class="nav">
<ui-col vertical-align="middle" align="left" space-left="10" width="70" bindtap="navigateBack">
<ui-icon type="arrow-left" size="16" color="#fff"></ui-icon>
</ui-col>
<ui-col>
</ui-col>
<ui-col vertical-align="middle" align="center" width="70">
<ui-icon type="more" size="24" color="#fff"></ui-icon>
</ui-col>
</ui-row>
</ui-nav-bar>
<ui-view class="blur-box">
<ui-blur url="{{fileUrl+store.fj_root+store.fj_name}}" height="{{DEFAULT_HEADER_HEIGHT+89}}"></ui-blur>
</ui-view>
<ui-view class="top_box" style="{{ {marginTop:DEFAULT_HEADER_HEIGHT+'px'}}}"> 
<ui-row class="nav2">
<ui-col space="20" class="col-w">
<ui-image class="imgbox" src="{{fileUrl+store.fj_root+store.fj_name}}"></ui-image>
</ui-col>
<ui-col>
<ui-view class="nav_right">
<ui-text class="t1" block>北京麦当劳芳菲路餐厅</ui-text>
<ui-text block>商家配送 | 28分钟送达 | 配送费¥9</ui-text>
<ui-text block>公告:欢迎光临,用餐高峰期请提前下单,谢谢</ui-text>
</ui-view> 
</ui-col>
</ui-row>
</ui-view>
 
<ui-tab-view class="text-zoomIn">
<template slot="header">
<ui-row height="46" class="tabs">
<ui-tab-view-header>预定</ui-tab-view-header>
<ui-tab-view-header>套餐</ui-tab-view-header>
<ui-tab-view-header>商家</ui-tab-view-header>
</ui-row>
</template>
<template slot="body">
<ui-tab-view-body>
<ui-view class="tab-content">
<!-- 商品 -->
<ui-row>
<!-- tab -->
<ui-col border-right width="100">
<ui-v-tabs
height="{{ WIN_HEIGHT-201}}"
index="{{ current }}"
probe=1
bindchange="handleChange($event, 'current')">
<ui-v-tab ui:for="{{ tabItems }}">
{{ item.name }}
</ui-v-tab>
</ui-v-tabs>
</ui-col>
<!-- 商品列表 -->
<ui-col class="goods-list">
<ui-scroll-view height="{{ WIN_HEIGHT-201}}" bindscroll="scroll($event, 'current')" probe="2" background-color="#fff" scroll-y scroll-into-view="{{toView}}">
<ui-view ui:for="{{goodsList}}" ui:for-index="index" ui:for-item="goodsItem" id="{{goodsItem.id}}">
<ui-divider>{{goodsItem.name}}</ui-divider>
<ui-row height="70" border-bottom ui:for="{{goodsItem.items}}" ui:for-item="item" ui:for-index="index">
<ui-col vertical-align="middle" width="70" space-left="10">
<ui-image class="imgbox" src="{{ item.imgSrc }}" width="70" height="70"></ui-image>
</ui-col>
<ui-col vertical-align="middle" space-left="16">
<ui-view class="goods-list-right">
<ui-text block class="t1">{{ item.title }}</ui-text>
<ui-text class="t2">{{ item.tips }}</ui-text>
<ui-text class="t3">{{ item.price }}</ui-text>
</ui-view>
</ui-col>
</ui-row>
</ui-view>
</ui-scroll-view>
</ui-col>
</ui-row>
</ui-view>
</ui-tab-view-body>
<ui-tab-view-body>
<ui-view class="tab-content">内容2</ui-view>
</ui-tab-view-body>
<ui-tab-view-body >
<ui-view class="tab-content">
<ui-view class="sample_content">
<ui-view>商家信息</ui-view>
<ui-text>{{store.introduce}}</ui-text>
</ui-view>
<ui-row class="sjinfo_row">
<ui-col span="3" align="left" vertical-align="middle">
商家名称
</ui-col>
<ui-col span="9" align="right" vertical-align="middle">
<ui-text>{{store.name}}</ui-text>
</ui-col>
</ui-row>
<ui-row class="sjinfo_row">
<ui-col span="3" align="left" vertical-align="middle">
商家地址
</ui-col>
<ui-col span="9" align="right" vertical-align="middle">
<ui-text>{{store.address}}</ui-text>
</ui-col>
</ui-row>
<ui-row class="sjinfo_row">
<ui-col span="3" align="left" vertical-align="middle">
商家电话
</ui-col>
<ui-col span="9" align="right" vertical-align="middle">
<ui-text bindtap="phone(store.phone)">{{store.phone}}</ui-text>
</ui-col>
</ui-row>
</ui-view>
</ui-tab-view-body>
</template>
</ui-tab-view>
</ui-page>
</template> 
<script>
export default {
config: {
"navigationStyle": "custom",
"disableScroll":true,
navigationBarTextStyle: 'white'
},
data () {
return {
WIN_HEIGHT:ui.WIN_HEIGHT,
DEFAULT_HEADER_HEIGHT:ui.DEFAULT_HEADER_HEIGHT,
storeId:'',//店铺编码
store:{},//店铺信息
fileUrl:ui.getApp().globalData.fileUrl,//文件url
current: 0,
toView: '',
tabItems: [
{ name: '热销榜' }
],
goodsList: [
{
name: '热销榜',
id: 'id0',
items: [
{
imgSrc: 'http://images.uileader.com/20171210/daa30780-d727-45dc-9c62-f4378deb5c9d.png',
title: '麦辣鸡翅两块',
tips: '月售178份 好评率100%',
price: '¥11'
}
]
}
]
}
},
methods: {
//返回上一页
navigateBack () {
ui.navigateBack()
},
//拨打电话
phone (phone){
ui.makePhoneCall({
phoneNumber: phone
})
},
//获取URL参数 商店ID
getStoreId(){
let getData=ui.getQuery();
this.storeId=getData.id;
if(getData.id){
this.getOneStore();
}else{
ui.showAlert({
title: '错误',
content: '系统故障,请稍后再试!!'
})
}
},
//获取商店信息
getOneStore(){
ui.request({
url: ui.getApp().globalData.bipUrl, //接口地址
data: {
"dbid": ui.getApp().globalData.dbid,
"usercode": "admin",
"apiId": "assisto", //outlogin(无密码)|login(有密码)需加pwd字段
"pageSize":1,
"page":1,
"assistid": 'GETSTORES',
"cont":'~sid='+this.storeId,
},
header: {
'content-type': 'application/json'
},
success: function (res) {
if(res.data.id==-1){
ui.showAlert({
title: '错误',
content: '系统故障,请稍后再试!!'
})
}else{
this.store = res.data.values[0];
}
}
})
}
},
mounted () {
this.getStoreId();
}
}
</script> 
<style lang="less">
.blur-box{
position:absolute;
top:0;
height:135px;
width:100%;
}
.top_box{
height:89px;
}
.nav{
z-index:9;
}
.nav2{
z-index:9;
.nav_right{
color:#fff;
font-size:12px;
line-height:24px;
margin-top:3px;
.t1{
font-size:16px;
}
}
.col-w{
flex:0 0 100px;
top:22px;
.imgbox{
box-shadow: 0px 5px 10px -2px #9a9a9a;
width:100%;
border-radius: 5px;
overflow: hidden;
.ui-image{
width:100%;
}
}
}

.tabs{
margin-top:20px;
 

.goods-list{
.imgbox{
.ui-image{
width:100%;
}
}
.goods-list-right{
font-size:12px;
.t1{
font-size:14px;
}
.t3{
color:#e60012
}
}
}
.sjinfo_row{
height:50px;
}
.tab-content{
margin-right: 5px;
margin-left: 5px;
}
</style>
QQ截图20180613185610.png QQ截图20180613185702.png
已邀请:

peng

赞同来自:

以下示例,1秒后页面上显示store.a为1
<template>
<ui-page>
<ui-text>{{ store.a }}</ui-text>
</ui-page>
</template>
<script>
export default {
data () {
return { store: {} }
},

mounted () {
window.setTimeout(() => {
this.store = { a: 1, b: 2 }
}, 1000)
}
}
</script>

Li_Zhengguo

赞同来自:

我在 ui.request 的 success 方法里面赋的值 这样不行吗?
 
ui.request({
url: ui.getApp().globalData.bipUrl, //接口地址
data: {
"dbid": ui.getApp().globalData.dbid,
"usercode": "admin",
"apiId": "assisto", //outlogin(无密码)|login(有密码)需加pwd字段
"pageSize":1,
"page":1,
"assistid": 'GETSTORES',
"cont":'~sid='+this.storeId,
},
header: {
'content-type': 'application/json'
},
success: function (res) {
if(res.data.id==-1){
ui.showAlert({
title: '错误',
content: '系统故障,请稍后再试!!'
})
}else{
this.store = res.data.values[0];
}
}
})

要回复问题请先登录注册



QQ:378966107

邮箱:frank@uileader.com

微信进交流群 加小助手微信进交流群