微信小程序?qū)崙?zhàn)篇-個(gè)人中心丈冬、訂單制作

哈嘍,大家好甘畅,又到周五啦埂蕊,有木有期待今天的更新呀~今天要教大家的是制作個(gè)人中心界面,先上效果圖

個(gè)人中心制作

  1. mine.js
// pages/mine/mine.js
var app = getApp()
Page({
  data: {
    userInfo: {},
    motto: 'Hello World',
    // orderItems
    orderItems: [
      {
        typeId: 0,
        name: '待付款',
        url: 'bill',
        imageurl: '../../images/person/personal_pay.png',
      },
      {
        typeId: 1,
        name: '待發(fā)貨',
        url: 'bill',
        imageurl: '../../images/person/personal_shipped.png',
      },
      {
        typeId: 2,
        name: '待收貨',
        url: 'bill',
        imageurl: '../../images/person/personal_receipt.png'
      },
      {
        typeId: 3,
        name: '待評(píng)價(jià)',
        url: 'bill',
        imageurl: '../../images/person/personal_comment.png'
      }
    ],
  },
  //事件處理函數(shù)
  toOrder: function () {
    wx.navigateTo({
      url: '../order/order'
    })
  },
  onLoad: function () {
    console.log('onLoad')
    var that = this
    //調(diào)用應(yīng)用實(shí)例的方法獲取全局?jǐn)?shù)據(jù)
    app.getUserInfo(function (userInfo) {
      //更新數(shù)據(jù)
      that.setData({
        userInfo: userInfo
      })
    })
  }
})

toOrder :事件監(jiān)聽(tīng)疏唾,跳轉(zhuǎn)到我的訂單界面
onLoad:在加載過(guò)程中蓄氧,獲取用戶的信息

  1. mine.wxml
<!--pages/mine/mine.wxml-->
<view class="container">

  <view class="userinfo">
    <image class="userinfo-avatar" src="{{userInfo.avatarUrl}}" background-size="cover"></image>
    <text class="userinfo-nickname">{{userInfo.nickName}}</text>
    <image src="../../images/person/account_bg.png" class="account-bg">
    </image>
  </view>

  <view class="separate"></view>

  <view class="order" catchtap="toOrder">
    <text class="myorder-text">我的訂單</text>
    <text class="myorderlook-text">查看全部訂單</text>
    <image class="next-image" src="../../images/person/next.png"></image>
  </view>
  <view class="line"></view>

  <view class="navs">
    <block wx:for-items="{{orderItems}}" wx:key="name">
      <view class="nav-item" catchtap="toOrder" data-type="{{item.name}}" data-typeid="{{item.typeId}}">
        <image src="{{item.imageurl}}" class="nav-image" />
        <text>{{item.name}}</text>
      </view>
    </block>
  </view>

  <view class="separate"></view>
  <view class="person-list">
    <view class="list-item">
      <image class="item-image" src="../../images/person/personal_favorite.png"></image>
      <text class="item-text">我的收藏</text>
    </view>
    <view class="person-line"></view>
    <view class="list-item">
      <image class="item-image" src="../../images/person/personal_site.png"></image>
      <text class="item-text">收貨地址</text>
    </view>
    <view class="person-line"></view>
    <view class="list-item">
      <image class="item-image" src="../../images/person/personal_sale_record.png"></image>
      <text class="item-text">售后記錄</text>
    </view>
    <view class="person-line"></view>
    <view class="list-item">
      <image class="item-image" src="../../images/person/personal_evaluated.png"></image>
      <text class="item-text">我的評(píng)價(jià)</text>
    </view>
    <view class="person-line"></view>
    <view class="list-item">
      <image class="item-image" src="../../images/person/personal_share.png"></image>
      <text class="item-text">推廣邀請(qǐng)</text>
    </view>
  </view>
  <view class="separate"></view>
</view>

布局分為三個(gè)模塊,用戶信息模塊槐脏、我的訂單模塊喉童、功能列表模塊,布局不是很難顿天,相信看源碼就可以理解

  1. mine.wxss
/* pages/mine/mine.wxss */
.userinfo {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #f0145a;
}
.account-bg {
  width: 100%;
  height: 150rpx;
}
.userinfo-avatar {
  width: 108rpx;
  height: 108rpx;
  margin: 20rpx;
  border-radius: 50%;
}
.userinfo-nickname {
  color: #fff;
}
/* 訂單 */
.order {
  display: flex;
  flex-direction: row;
  align-items: center;
  width: 100%;
  height: 90rpx;
}
.myorder-text {
  font-size: 30rpx;
  color: gray;
  margin: 20rpx;
  width: 40%;
}
.myorderlook-text {
  font-size: 30rpx;
  color: gray;
  position: relative;
  right: 20rpx;
  width: 60%;
  text-align: right;
}
.next-image {
  width: 20rpx;
  height: 25rpx;
  position: relative;
  right: 10rpx;
}
.navs {
  display: flex;
}
.nav-item {
  width: 25%;
  display: flex;
  align-items: center;
  flex-direction: column;
  padding: 20rpx;
}
.nav-item .nav-image {
  width: 40rpx;
  height: 40rpx;
  margin: 5rpx;
}
.nav-item text {
  margin-top: 20rpx;
  font-size: 25rpx;
  color: gray;
}
/* 列表 */
.person-list {
  display: flex;
  flex-direction: column;
  align-items: left;
}
.list-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  height: 80rpx;
}
.item-image {
  width: 40rpx;
  height: 40rpx;
  margin: 20rpx;
}
.item-text {
  color: gray;
  font-size: 25rpx;
  margin-left: 20rpx;
}
.person-line {
  width: 100%;
  height: 2rpx;
  background: lightgray;
  margin-left: 90rpx;
}

樣式列表我重點(diǎn)講解一下 userinfo-avatar 類中的 border-radius 屬性堂氯,大家看一下效果就知道他的作用,沒(méi)錯(cuò)設(shè)置圓角圖片牌废,正常我們都是方方正正的圖片咽白,有了這個(gè)屬性,可以輕松實(shí)現(xiàn)圓角圖片了

我的訂單制作

我的訂單鸟缕,其實(shí)界面的實(shí)現(xiàn)原理和首頁(yè)的導(dǎo)航欄是一樣的晶框,只不過(guò)換了一下內(nèi)容以及導(dǎo)航欄標(biāo)題罷了,所以這里我就不細(xì)講了叁扫,不懂的朋友可以看我首頁(yè)導(dǎo)航欄是怎么制作的三妈,模仿寫出來(lái)就好

  1. order.js
// pages/order/order.js
var Zan = require('../../template/contract.js');
Page(Object.assign({}, Zan.Tab, {
  data: {
    tab1: {
      list: [{
        id: 0,
        title: '全部'
      }, {
        id: 1,
        title: '待付款'
      }, {
        id: 2,
        title: '待發(fā)貨'
      }, {
        id: 3,
        title: '待收貨'
      }, {
        id: 4,
        title: '待評(píng)價(jià)'
      }],
      selectedId: 0,
      scroll: false,
    },
  },
  handleZanTabChange(e) {
    var componentId = e.componentId;
    var selectedId = e.selectedId;
    this.setData({
      `${componentId}.selectedId`: selectedId
    });
  }
}));
  1. order.wxml
<!--pages/order/order.wxml-->
<import src="/template/tab/tab.wxml" />
 <view class="tab">
    <template is="zan-tab" data="{{tab: tab1, componentId: 'tab1'}}"></template>
  </view>
<view class="tab-content1" >
<image class="tab-image" src="../../images/order/non_cart.png"></image>
<text>您還沒(méi)有相關(guān)訂單哦!</text>
</view>
  1. order.wxss
/* pages/order/order.wxss */
.tab-content1
{
  display: flex;
  flex-direction: column;
  align-items: center;
}
.tab-image
{
  width: 50%;
  margin-top: 130rpx;
  margin-bottom: 50rpx;
}

原文地址:http://www.wxapp-union.com/article-2820-1.html

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末莫绣,一起剝皮案震驚了整個(gè)濱河市畴蒲,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌对室,老刑警劉巖模燥,帶你破解...
    沈念sama閱讀 211,194評(píng)論 6 490
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異掩宜,居然都是意外死亡蔫骂,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,058評(píng)論 2 385
  • 文/潘曉璐 我一進(jìn)店門牺汤,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)辽旋,“玉大人,你說(shuō)我怎么就攤上這事〔古撸” “怎么了码耐?”我有些...
    開(kāi)封第一講書人閱讀 156,780評(píng)論 0 346
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)溶其。 經(jīng)常有香客問(wèn)我骚腥,道長(zhǎng),這世上最難降的妖魔是什么瓶逃? 我笑而不...
    開(kāi)封第一講書人閱讀 56,388評(píng)論 1 283
  • 正文 為了忘掉前任束铭,我火速辦了婚禮,結(jié)果婚禮上厢绝,老公的妹妹穿的比我還像新娘契沫。我一直安慰自己,他們只是感情好代芜,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,430評(píng)論 5 384
  • 文/花漫 我一把揭開(kāi)白布埠褪。 她就那樣靜靜地躺著,像睡著了一般挤庇。 火紅的嫁衣襯著肌膚如雪钞速。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書人閱讀 49,764評(píng)論 1 290
  • 那天嫡秕,我揣著相機(jī)與錄音渴语,去河邊找鬼。 笑死昆咽,一個(gè)胖子當(dāng)著我的面吹牛驾凶,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播掷酗,決...
    沈念sama閱讀 38,907評(píng)論 3 406
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼调违,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了泻轰?” 一聲冷哼從身側(cè)響起技肩,我...
    開(kāi)封第一講書人閱讀 37,679評(píng)論 0 266
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎浮声,沒(méi)想到半個(gè)月后虚婿,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 44,122評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡泳挥,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,459評(píng)論 2 325
  • 正文 我和宋清朗相戀三年然痊,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片屉符。...
    茶點(diǎn)故事閱讀 38,605評(píng)論 1 340
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡剧浸,死狀恐怖锹引,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情辛蚊,我是刑警寧澤粤蝎,帶...
    沈念sama閱讀 34,270評(píng)論 4 329
  • 正文 年R本政府宣布,位于F島的核電站袋马,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏秸应。R本人自食惡果不足惜虑凛,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,867評(píng)論 3 312
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望软啼。 院中可真熱鬧桑谍,春花似錦、人聲如沸祸挪。這莊子的主人今日做“春日...
    開(kāi)封第一講書人閱讀 30,734評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)贿条。三九已至雹仿,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間整以,已是汗流浹背胧辽。 一陣腳步聲響...
    開(kāi)封第一講書人閱讀 31,961評(píng)論 1 265
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留公黑,地道東北人邑商。 一個(gè)月前我還...
    沈念sama閱讀 46,297評(píng)論 2 360
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像凡蚜,于是被迫代替她去往敵國(guó)和親人断。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,472評(píng)論 2 348

推薦閱讀更多精彩內(nèi)容