userInfor.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template>
  2. <view class="userInfor acea-row row-between-wrapper" :class="{pageOn:itemStyle===0}"
  3. :style="{marginLeft:prConfig+'rpx',marginRight:prConfig+'rpx',marginTop:mbCongfig+'rpx',background:bgColor}" v-show="!isSortType" @click="goLogin">
  4. <view class="left acea-row row-middle" :style="'color:'+textColor">
  5. <view class="pictrue acea-row row-center-wrapper">
  6. <image :src="diyInfo.avatar" v-if="diyInfo.avatar && isLogin"></image>
  7. <image v-if="!diyInfo.avatar && isLogin" src="@/static/images/f.png"></image>
  8. <image v-if="!isLogin" src="@/static/images/f.png"></image>
  9. </view>
  10. <view class="text">
  11. <view v-if="!isLogin" class="name">点击登录</view>
  12. <view v-else class="name acea-row row-middle">
  13. <view class="nameCon line1">{{diyInfo.nickname}}</view>
  14. <view class="lable" v-if="diyInfo.level>0"><text class="iconfont icon-v"></text>{{diyInfo.vip_name}}</view>
  15. </view>
  16. <view class="acea-row row-middle" v-if="isLogin && diyInfo.level>0">
  17. <view class="progress">
  18. <view class='bg-reds' :style="'width:'+(diyInfo.exp>diyInfo.next_exp?100:$util.$h.Div(parseInt(diyInfo.exp), diyInfo.next_exp)>=5?$util.$h.Div(parseInt(diyInfo.exp), diyInfo.next_exp):5)+'%;background:linear-gradient(90deg, '+progressColor[0].item+' 0%,'+progressColor[1].item+' 100%);'"></view>
  19. </view>
  20. <view class="percent">{{diyInfo.exp?diyInfo.exp.split('.')[0]:0}}/{{diyInfo.next_exp || 0}}</view>
  21. </view>
  22. <view class="phone acea-row row-middle" v-if="isLogin && diyInfo.level<=0 && diyInfo.phone">
  23. <text class="iconfont icon-shouji2"></text>
  24. <text>{{diyInfo.phone}}</text>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="right acea-row row-bottom" :style="'color:'+textColor">
  29. <view class="item" v-if="diyInfo.level>0 && checkType.indexOf(1) != -1" @click.stop="goIntegral">
  30. <view class="num">{{diyInfo.integral||2}}</view>
  31. <view>积分</view>
  32. </view>
  33. <view class="item" v-if="diyInfo.level>0 && checkType.indexOf(2) != -1" @click.stop="goMoney">
  34. <view class="num">{{diyInfo.now_money||6}}</view>
  35. <view>余额</view>
  36. </view>
  37. <view class="item" v-if="checkType.indexOf(0) != -1" @click.stop="goCoupon">
  38. <view class="num">{{diyInfo.coupon_num||0}}</view>
  39. <view>优惠券</view>
  40. </view>
  41. <view class="item" v-if="(diyInfo.level == 0 && checkType.indexOf(3) != -1) || !isLogin" @click.stop="tapQrCode">
  42. <view class="iconfont icon-erweima3"></view>
  43. <view>会员码</view>
  44. </view>
  45. </view>
  46. <view class="codePopup" :style="colorStyle" v-show="isCode">
  47. <view class="header acea-row row-between-wrapper">
  48. <view class="title" :class="{'on': codeIndex == index,'onLeft':codeIndex == 1}"
  49. v-for="(item, index) in codeList" :key="index" @click="tapCode(index)">{{item.name}}</view>
  50. </view>
  51. <view>
  52. <view class="acea-row row-center-wrapper">
  53. <w-barcode :options="config.bar"></w-barcode>
  54. </view>
  55. <view class="acea-row row-center-wrapper" style="margin-top: 35rpx;">
  56. <w-qrcode :options="config.qrc" @generate="hello"></w-qrcode>
  57. </view>
  58. <view class="codeNum">{{config.bar.code}}</view>
  59. <view class="tip">如遇到扫码失败请将屏幕调至最亮重新扫码</view>
  60. </view>
  61. <view class="iconfont icon-guanbi2" @click="closeCode"></view>
  62. </view>
  63. <view class="mark" v-if="isCode"></view>
  64. </view>
  65. </template>
  66. <script>
  67. import colors from "@/mixins/color";
  68. import {
  69. diyUserInfo
  70. } from '@/api/api.js';
  71. import {
  72. getRandCode
  73. } from '@/api/user.js';
  74. import {
  75. mapGetters
  76. } from 'vuex';
  77. export default {
  78. computed: mapGetters(['isLogin']),
  79. name: 'userInfor',
  80. props: {
  81. dataConfig: {
  82. type: Object,
  83. default: () => {}
  84. },
  85. isSortType: {
  86. type: String | Number,
  87. default: 0
  88. }
  89. },
  90. mixins: [colors],
  91. data() {
  92. return {
  93. config: {
  94. bar: {
  95. code: '',
  96. color: ['#000'],
  97. bgColor: '#FFFFFF', // 背景色
  98. width: 480, // 宽度
  99. height: 110 // 高度
  100. },
  101. qrc: {
  102. code: '',
  103. size: 380, // 二维码大小
  104. level: 3, //等级 0~4
  105. bgColor: '#FFFFFF', //二维码背景色 默认白色
  106. border: {
  107. color: ['#eee', '#eee'], //边框颜色支持渐变色
  108. lineWidth: 3, //边框宽度
  109. },
  110. // img: '/static/logo.png', //图片
  111. // iconSize: 40, //二维码图标的大小
  112. color: ['#333', '#333'], //边框颜色支持渐变色
  113. }
  114. },
  115. codeList: [{
  116. name: '会员码'
  117. }, {
  118. name: '付款码'
  119. }],
  120. codeIndex: 0,
  121. isCode: false,
  122. bgColor: this.dataConfig.bgColor.color[0].item,
  123. textColor: this.dataConfig.textColor.color[0].item,
  124. progressColor: this.dataConfig.progressColor.color,
  125. mbCongfig: this.dataConfig.mbCongfig.val*2,
  126. prConfig: this.dataConfig.prConfig.val*2, //背景边距
  127. itemStyle: this.dataConfig.itemStyle.type,
  128. checkType: this.dataConfig.checkboxInfo.type,
  129. diyInfo:{}
  130. }
  131. },
  132. created() {
  133. if (this.isLogin) {
  134. this.getDiyUserInfo();
  135. }
  136. },
  137. watch: {
  138. isLogin: {
  139. handler: function(newV, oldV) {
  140. if (newV) {
  141. this.getDiyUserInfo();
  142. }
  143. },
  144. deep: true
  145. }
  146. },
  147. methods: {
  148. hello(res) {
  149. // console.log(321,res)
  150. },
  151. getCode() {
  152. getRandCode().then(res => {
  153. let code = res.data.code;
  154. this.config.bar.code = code;
  155. this.config.qrc.code = code;
  156. }).catch(err => {
  157. return this.$util.Tips(err);
  158. })
  159. },
  160. tapQrCode() {
  161. this.isCode = true;
  162. this.codeIndex = 0;
  163. this.$nextTick(function() {
  164. let code = this.diyInfo.bar_code;
  165. this.config.bar.code = code;
  166. this.config.qrc.code = code;
  167. })
  168. },
  169. closeCode() {
  170. this.isCode = false
  171. this.isextension = false
  172. },
  173. tapCode(index) {
  174. this.codeIndex = index;
  175. if (index == 1) {
  176. this.getCode();
  177. } else {
  178. let code = this.diyInfo.bar_code;
  179. this.config.bar.code = code;
  180. this.config.qrc.code = code;
  181. }
  182. },
  183. goIntegral(){
  184. uni.navigateTo({
  185. url: '/pages/users/user_integral/index'
  186. })
  187. },
  188. goMoney(){
  189. uni.navigateTo({
  190. url: '/pages/users/user_money/index'
  191. })
  192. },
  193. goCoupon(){
  194. uni.navigateTo({
  195. url: '/pages/users/user_coupon/index'
  196. })
  197. },
  198. goLogin(){
  199. if(!this.isLogin){
  200. this.$emit('changeLogin');
  201. }
  202. },
  203. getDiyUserInfo(){
  204. diyUserInfo().then(res=>{
  205. this.diyInfo = res.data;
  206. }).catch(err=>{
  207. this.$util.Tips({
  208. title: err
  209. });
  210. })
  211. }
  212. }
  213. }
  214. </script>
  215. <style lang="scss">
  216. .userInfor {
  217. padding: 28rpx 20rpx;
  218. .mark {
  219. position: fixed;
  220. top: 0;
  221. left: 0;
  222. bottom: 0;
  223. right: 0;
  224. background: rgba(0, 0, 0, 0.5);
  225. z-index: 50;
  226. }
  227. .codePopup .icon-guanbi2{
  228. margin-top: 75rpx !important;
  229. }
  230. &.pageOn {
  231. border-radius: 12rpx;
  232. }
  233. .right {
  234. .item {
  235. text-align: center;
  236. font-weight: 400;
  237. //color: #666666;
  238. font-size: 20rpx;
  239. margin-left: 32rpx;
  240. .num {
  241. font-size: 28rpx;
  242. margin-bottom: 4rpx;
  243. }
  244. }
  245. .iconfont {
  246. font-weight: 400;
  247. //color: #333333;
  248. font-size: 30rpx;
  249. margin-bottom: 4rpx;
  250. }
  251. }
  252. .left {
  253. .pictrue {
  254. width: 90rpx;
  255. height: 90rpx;
  256. border: 1px solid #EEEEEE;
  257. border-radius: 50%;
  258. margin-right: 24rpx;
  259. image{
  260. width: 100%;
  261. height: 100%;
  262. border-radius: 50%;
  263. }
  264. }
  265. .text {
  266. font-weight: 400;
  267. //color: #333333;
  268. font-size: 28rpx;
  269. .name{
  270. margin-bottom: 10rpx;
  271. .nameCon{
  272. max-width: 190rpx;
  273. }
  274. .lable{
  275. background: #FFE8CA;
  276. border-radius: 20rpx;
  277. padding:2rpx 10rpx;
  278. margin-left: 12rpx;
  279. font-size: 20rpx;
  280. color: #333;
  281. .icon-v{
  282. margin-right: 4rpx;
  283. font-size: 24rpx;
  284. }
  285. }
  286. }
  287. .progress{
  288. overflow: hidden;
  289. background-color: #EEEEEE;
  290. width: 144rpx;
  291. height: 14rpx;
  292. border-radius: 7rpx;
  293. position: relative;
  294. margin-right: 6rpx;
  295. .bg-reds{
  296. width: 0;
  297. height: 100%;
  298. transition: width 0.6s ease;
  299. background: linear-gradient(90deg, rgba(233, 51, 35, 1) 0%, rgba(255, 137, 51, 1) 100%);
  300. }
  301. }
  302. .percent{
  303. font-size: 20rpx;
  304. }
  305. .phone {
  306. font-weight: 400;
  307. //color: #666666;
  308. font-size: 20rpx;
  309. margin-top: 6rpx;
  310. .icon-shouji2 {
  311. margin-right: 4rpx;
  312. font-size: 20rpx;
  313. }
  314. }
  315. }
  316. }
  317. }
  318. </style>