builtinBgImg.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <view class="content">
  3. <!-- #ifdef MP-WEIXIN -->
  4. <u-navbar title=" " :background="{ background: '#F6F7F8'}" :border-bottom="false" back-icon-name="" back-text="取消" :back-text-style="{color:'#404133'}">
  5. <view class="slot-wrap" slot="right">
  6. <u-button size="mini" type="success" @click="handleLink" >完成</u-button>
  7. </view>
  8. </u-navbar>
  9. <!-- #endif -->
  10. <u-grid @click="clickGrid">
  11. <u-grid-item v-for="(item, index) in bgList" :key="index" :index="index">
  12. <image :src="item.src" class="img" mode="scaleToFill"></image>
  13. <view class="check-box" v-show="item.isCheck"><u-icon style="display: inline-block;" name="checkbox-mark"></u-icon></view>
  14. </u-grid-item>
  15. </u-grid>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. data() {
  21. return {
  22. bgList:[]
  23. };
  24. },
  25. methods: {
  26. clickGrid(index){
  27. this.bgList.forEach((item,i)=>{
  28. if(index == i) item.isCheck = !item.isCheck;
  29. else item.isCheck = false;
  30. })
  31. },
  32. //自定义标题栏按钮 h5&&app
  33. onNavigationBarButtonTap({ index }) {
  34. if (index == 0) {
  35. this.handleLink()
  36. }
  37. },
  38. //处理跳转逻辑
  39. handleLink(){
  40. const item = this.bgList.find(it=>it.isCheck);
  41. if(item){
  42. this.$u.vuex('userData.user.pictureBanner', item.src);
  43. this.$u.route({ type: 'back',delta:2});
  44. }
  45. },
  46. },
  47. onShow() {
  48. this.bgList = JSON.parse(JSON.stringify(this.circleBgList))
  49. }
  50. };
  51. </script>
  52. <style lang="scss" scoped>
  53. .content {
  54. .img {
  55. width: calc(750rpx / 3.4);
  56. height: calc(750rpx / 3.4);
  57. }
  58. .check-box{
  59. position: absolute;
  60. bottom: 0;
  61. left: 0;
  62. width: 100%;
  63. height: 40rpx;
  64. line-height: 40rpx;
  65. background-color: $u-type-success;
  66. opacity: 0.7;
  67. text-align: center;
  68. color:#FFFFFF;
  69. }
  70. .slot-wrap {
  71. display: flex;
  72. align-items: center;
  73. padding: 0 30rpx;
  74. }
  75. }
  76. </style>