middle.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <view>
  3. <view class="title">自定义样式</view>
  4. <view class="photo">大家好</view>
  5. <t-table border="2" border-color="#95b99e" :is-check="true" @change="change">
  6. <t-tr font-size="14" color="#95b99e" align="left">
  7. <t-th align="left">姓名</t-th>
  8. <t-th align="left">年龄</t-th>
  9. <t-th align="left">爱好</t-th>
  10. <t-th align="center">操作</t-th>
  11. </t-tr>
  12. <t-tr font-size="12" color="#5d6f61" align="right" v-for="item in tableList" :key="item.id">
  13. <t-td align="left">{{ item.name }}</t-td>
  14. <t-td align="left">{{ item.age }}</t-td>
  15. <t-td align="left">{{ item.hobby }}</t-td>
  16. <t-td align="left"><button @click="edit(item)">编辑</button></t-td>
  17. </t-tr>
  18. </t-table>
  19. <button @click="add">添加</button>
  20. <view>{{obj.name}}</view>
  21. <view>{{obj.age}}</view>
  22. <view class="form-box">
  23. <u-form :model="form" ref="uForm" :border-bottom='false'>
  24. <u-form-item label="账号">
  25. <u-input v-model="form.name" border />
  26. </u-form-item>
  27. <u-form-item label="密码">
  28. <u-input v-model="form.password" border type='password' password-icon />
  29. </u-form-item>
  30. </u-form>
  31. <u-button :ripple="true" type="primary" @click="goLogin">登录</u-button>
  32. </view>
  33. <view>{{uerInfo.name}}</view>
  34. <view>{{uerInfo.password}}</view>
  35. <u-toast ref="uToast"></u-toast>
  36. </view>
  37. </template>
  38. <script>
  39. import tTable from '@/components/t-table/t-table.vue';
  40. import tTh from '@/components/t-table/t-th.vue';
  41. import tTr from '@/components/t-table/t-tr.vue';
  42. import tTd from '@/components/t-table/t-td.vue';
  43. import {
  44. mapState,
  45. mapMutations
  46. } from 'vuex';
  47. export default {
  48. components: {
  49. tTable,
  50. tTh,
  51. tTr,
  52. tTd
  53. },
  54. data() {
  55. return {
  56. borderBottom: false,
  57. labelPosition: "top",
  58. tableList: [{
  59. id: 11,
  60. name: '张三',
  61. age: '19',
  62. hobby: '游泳'
  63. },
  64. {
  65. id: 1,
  66. name: '李四',
  67. age: '21',
  68. hobby: '绘画'
  69. },
  70. {
  71. id: 2,
  72. name: '王二',
  73. age: '29',
  74. hobby: '滑板'
  75. },
  76. {
  77. id: 3,
  78. name: '码字',
  79. age: '20',
  80. hobby: '蹦极'
  81. }
  82. ],
  83. obj: {
  84. name: '查娜',
  85. },
  86. form: {
  87. user: '',
  88. password: '',
  89. },
  90. };
  91. },
  92. onLoad() {
  93. },
  94. methods: {
  95. ...mapMutations(['login']),
  96. change(e) {
  97. console.log(e.detail);
  98. },
  99. edit(item) {
  100. uni.showToast({
  101. title: item.name,
  102. icon: 'none'
  103. });
  104. },
  105. add() {
  106. this.$set(this.obj, `age`, 50);
  107. console.log(this.obj)
  108. },
  109. toUser(data) {
  110. this.login(data);
  111. uni.reLaunch({
  112. url: '/pages/index/index'
  113. })
  114. },
  115. goLogin() {
  116. this.$u.toast('验证码已发送');
  117. setTimeout(() => {
  118. this.toUser(this.form)
  119. }, 2000);
  120. },
  121. },
  122. computed: {
  123. ...mapState(['hasLogin', 'uerInfo']),
  124. },
  125. }
  126. </script>
  127. <style scoped>
  128. .photo {
  129. background: url(../../static/logo.png) no-repeat;
  130. background-size: contain;
  131. border: 1rpx solid red;
  132. height: 100rpx;
  133. line-height: 100rpx;
  134. width: 500rpx;
  135. text-align: center;
  136. }
  137. .form-box {
  138. width: 90%;
  139. margin: 0 auto;
  140. }
  141. .form-box /deep/.u-btn--primary {
  142. background-color: #19BE6B;
  143. }
  144. </style>