index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <view>
  3. <z-navbar bgcolor="white" color="#333333">
  4. <view slot="title" class="center_title flex-n fac">
  5. <view class="center_title_icon icon1 iconfont"></view>
  6. <view class="center_title_storename ml-23">{{info.storeName}}</view>
  7. </view>
  8. </z-navbar>
  9. <view class="shadow-2 center_top plr-50 pb-43">
  10. <view class="flex-n fac fjb">
  11. <view class="center_top_left">
  12. <view class="center_top_name">{{info.userName}}</view>
  13. <view class="center_top_text">{{info.roleName}}</view>
  14. <view class="center_top_text">{{info.phone||''}}</view>
  15. </view>
  16. <image class="center_top_right" :src="info.headImageSrc||'../../../static/touxiang_2.png'" @click="showInfo"></image>
  17. </view>
  18. </view>
  19. <user-info :visible.sync="showUserInfo" @changeImage="changeImage"></user-info>
  20. <view class="mt-50">
  21. <z-cell icon="iconbaobiao" v-if="!hideStateTab" :iconStyle="{'font-size': '36rpx','color':'#2d8cf0'}" label="报表统计" arrow @click.native="gotoReport"></z-cell>
  22. <z-cell icon="iconjuxing45" :iconStyle="{'font-size': '36rpx','color':'#2d8cf0'}" label="扫一扫" arrow @click.native="gotoScan"></z-cell>
  23. <z-cell icon="icon6" :iconStyle="{'font-size': '36rpx','color':'#2d8cf0'}" label="切换门店" arrow @click.native="tabStore"></z-cell>
  24. <store-list :visible.sync="showStoreList" @submit="checkedState(info)"></store-list>
  25. <z-cell icon="icon3" :iconStyle="{'font-size': '36rpx','color':'#2d8cf0'}" label="联系客服" arrow @click.native="showMakePhone=true"></z-cell>
  26. <z-cell icon="icon11" :iconStyle="{'font-size': '36rpx','color':'#2d8cf0'}" label="设置" arrow @click.native="gotoSetting"></z-cell>
  27. <z-cell icon="iconjuxing44" :iconStyle="{'font-size': '36rpx','color':'#2d8cf0'}" label="关于刺兔APP" arrow @click.native="gotoAbout"></z-cell>
  28. </view>
  29. <z-tabbar></z-tabbar>
  30. <u-toast ref="uToast"></u-toast>
  31. <z-select-popup :visible.sync="showMakePhone">
  32. <view @click="gotoMakePhone('17109909009')">17109909009</view>
  33. <view class="line"></view>
  34. <view @click="gotoMakePhone('17190909009')">17190909009</view>
  35. </z-select-popup>
  36. </view>
  37. </template>
  38. <script>
  39. const app = getApp({allowDefault: true});
  40. import storeList from '../../component/storeList/storeList.vue';
  41. import userInfo from './userInfo.vue';
  42. export default {
  43. components:{
  44. storeList,
  45. userInfo
  46. },
  47. name: 'index',
  48. data() {
  49. return {
  50. info:{},
  51. showStoreList:false,
  52. showUserInfo:false,
  53. showMakePhone:false,
  54. hideStateTab:false
  55. };
  56. },
  57. mounted() {
  58. uni.hideTabBar();
  59. // this.getMenu();
  60. },
  61. onShow(){
  62. if(uni.getStorageSync('storeInfo')){
  63. console.log(34)
  64. this.info=uni.getStorageSync('storeInfo')
  65. let that=this;
  66. if(!this.info.storeName){
  67. uni.getStorage({
  68. key:'storeInfo',
  69. success: (res) => {
  70. for(var i in res.data.store){
  71. if(res.data.store[i].storeId==uni.getStorageSync('storeId')){
  72. that.$set(that.info,'storeName',res.data.store[i].storeName);
  73. break;
  74. }
  75. }
  76. }
  77. })
  78. }
  79. }else{
  80. this.getData(app.globalData.userId);
  81. }
  82. this.getMenu();
  83. },
  84. methods:{
  85. getMenu(){
  86. uni.getStorage({
  87. key:'menu',
  88. success:(res)=>{
  89. console.log(res)
  90. if(res.data.indexOf('106')==-1){
  91. this.hideStateTab=true;
  92. }
  93. }
  94. })
  95. },
  96. changeImage(data){
  97. console.log(data)
  98. this.$set(this.info,'headImageSrc',data)
  99. },
  100. checkedState(info){
  101. var num=-1;
  102. for(var i in info.store){
  103. if(info.store[i].storeId==uni.getStorageSync('storeId')){
  104. this.info.storeName=info.store[i].storeName;
  105. num=i;
  106. break;
  107. }
  108. }
  109. //没有匹配门店
  110. if(num==-1){
  111. this.info.storeName=info.store[0].storeName;
  112. uni.setStorage({
  113. key:'storeId',
  114. data:info.store[0].storeId
  115. })
  116. uni.getStorage({
  117. key:'userInfo',
  118. success: (res) => {
  119. var userInfo=res.data;
  120. userInfo.storeId=info.store[0].storeId;
  121. uni.setStorage({
  122. key : 'userInfo',
  123. data:userInfo
  124. })
  125. }
  126. })
  127. }
  128. },
  129. getData(id){
  130. console.log(id)
  131. this.$axios.get('app/user/userInfo/'+id).then(res=>{
  132. console.log(res)
  133. this.info=res.data;
  134. uni.setStorage({
  135. key:'storeInfo',
  136. data:res.data
  137. })
  138. this.checkedState(res.data);
  139. }).catch(err=>{
  140. this.$refs.uToast.error(err.msg)
  141. })
  142. },
  143. gotoReport(){
  144. uni.navigateTo({
  145. url:'../report/report'
  146. })
  147. },
  148. tabStore(){
  149. this.showStoreList=true;
  150. },
  151. showInfo(){
  152. this.showUserInfo=true;
  153. },
  154. //拨打电话
  155. gotoMakePhone(phone){
  156. var that=this;
  157. uni.makePhoneCall({
  158. phoneNumber: phone,
  159. complete:function() {
  160. that.showMakePhone=false;
  161. }
  162. });
  163. },
  164. //扫码
  165. gotoScan(){
  166. uni.scanCode({
  167. success(res){
  168. console.log(res.result)
  169. },
  170. fail(err){
  171. }
  172. })
  173. },
  174. //设置
  175. gotoSetting(){
  176. uni.navigateTo({
  177. url: '../setting/index',
  178. success: res => {},
  179. fail: () => {},
  180. complete: () => {}
  181. });
  182. },
  183. //关于
  184. gotoAbout(){
  185. uni.navigateTo({
  186. url: '../about/index',
  187. success: res => {},
  188. fail: () => {},
  189. complete: () => {}
  190. });
  191. },
  192. }
  193. }
  194. </script>
  195. <style lang="scss">
  196. .center_title {
  197. width: 650rpx !important;
  198. text-align: left;
  199. .center_title_icon {
  200. width: 24rpx;
  201. height: 32rpx;
  202. font-size: 32rpx;
  203. color: #333333;
  204. }
  205. .center_title_storename {
  206. font-size: 36rpx;
  207. color: #333333;
  208. }
  209. }
  210. .center_top {
  211. .center_top_left {
  212. .center_top_name {
  213. font-size: 60rpx;
  214. font-weight: bold;
  215. color: #333333;
  216. }
  217. .center_top_text {
  218. font-size: 28rpx;
  219. color: #999999;
  220. line-height: 40rpx;
  221. font-weight: 500;
  222. }
  223. }
  224. .center_top_right {
  225. width: 200rpx;
  226. height: 200rpx;
  227. border-radius: 50%;
  228. border: 8rpx solid #eeeeee;
  229. }
  230. }
  231. </style>