honor.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <view class="content">
  3. <view>
  4. <uni-segmented-control :current="current" :values="items" @clickItem="onClickItem"
  5. styleType="text" activeColor="#1c9bdc"></uni-segmented-control>
  6. <view class="content">
  7. <view v-show="current == 0">
  8. <view class="active-title-box">
  9. <!--<uni-datetime-picker
  10. class="time-select-box"
  11. type="date"
  12. :value="single"
  13. @change="change"
  14. :clear-icon="false"
  15. /> -->
  16. <picker mode="date" fields="year" @change="bindDateChange" class="picker-class">
  17. <view class="uni-input display-between items-center">{{dateYear}}年<image src="/static/calendar_icon.svg" mode="aspectFit" style="top: 18rpx;"></image></view>
  18. </picker>
  19. <picker :range="arrayMonth" :value="dateMonth" @change="bindDateMonthChange" class="picker-class" style="margin-left: 2%;">
  20. <view class="uni-input display-between items-center" style="color: #707070;">{{dateMonth}}月<image src="/static/calendar_icon.svg" mode="aspectFit" style="top: 18rpx;"></image></view>
  21. </picker>
  22. <picker @change="bindPickerChange" :value="index" :range="array">
  23. <view class="uni-input">{{array[index]}}</view>
  24. <image src="/static/arrow_down.svg" mode="aspectFit"></image>
  25. </picker>
  26. <button @click="goRecord()">+获奖记录</button>
  27. </view>
  28. <view class="honor-box" v-for="(item,index) in honorList" :key="index" style="position: relative;">
  29. <view class="honor-name">{{item.name}}</view>
  30. <image :src="item.pic_url" mode="aspectFit" @click="showLarge(item.pic_url_resize)"></image>
  31. <view class="honor-award">获奖人:{{item.for_branch}} {{item.for_names}}</view>
  32. <view class="honor-info-box">
  33. <text>{{item.year}}年{{item.month}}月</text>
  34. <text>|</text>
  35. <text>{{item.level_str}}</text>
  36. <text>|</text>
  37. <text>{{item.from_str}}</text>
  38. <text>|</text>
  39. <text>{{item.for_str}}</text>
  40. </view>
  41. <view class="edit-icon-box">
  42. <image src="/static/edit-icon.png" mode="aspectFit" v-show="item.edit_auth"></image>
  43. <image src="/static/del-icon.png" mode="aspectFit" v-show="item.del_auth"></image>
  44. </view>
  45. </view>
  46. <view v-if="!honorList.length" style="text-align: center;">
  47. <image src="/static/nodata.svg" mode="aspectFit" style="width: 300rpx;height: 300rpx;"></image>
  48. </view>
  49. </view>
  50. <view v-show="current == 1">
  51. <view class="active-title-box">
  52. <picker mode="date" fields="year" @change="bindDateChangeSelf" class="picker-class">
  53. <view class="uni-input display-between items-center">{{dateYearSelf}}年<image src="/static/calendar_icon.svg" mode="aspectFit" style="top: 18rpx;"></image></view>
  54. </picker>
  55. <picker :range="arrayMonth" :value="dateMonthSelf" @change="bindDateMonthChangeSelf" class="picker-class" style="margin-left: 2%;">
  56. <view class="uni-input display-between items-center" style="color: #707070;">{{dateMonthSelf}}月<image src="/static/calendar_icon.svg" mode="aspectFit" style="top: 18rpx;"></image></view>
  57. </picker>
  58. <!-- <picker @change="bindPickerChangeSelf" :value="indexSelf" :range="arraySelf">
  59. <view class="uni-input">{{arraySelf[index]}}</view>
  60. <image src="/static/arrow_down.svg" mode="aspectFit"></image>
  61. </picker> -->
  62. <button @click="goRecord()" style="margin-left: 20%;">+获奖记录</button>
  63. </view>
  64. <view class="honor-box" v-for="(item,index) in myHonorList" :key="index" >
  65. <view class="honor-name">{{item.name}}</view>
  66. <image :src="item.pic_url" mode="aspectFit" @click="showLarge(item.pic_url_resize)"></image>
  67. <view class="honor-award">获奖人:{{item.for_branch}} {{item.for_names}}</view>
  68. <view class="honor-info-box">
  69. <text>{{item.year}}年{{item.month}}月</text>
  70. <text>|</text>
  71. <text>{{item.level_str}}</text>
  72. <text>|</text>
  73. <text>{{item.from_str}}</text>
  74. <text>|</text>
  75. <text>{{item.for_str}}</text>
  76. </view>
  77. <!--<view class="edit-icon-box">
  78. <image src="/static/edit-icon.png" mode="aspectFit"></image>
  79. <image src="/static/del-icon.png" mode="aspectFit"></image>
  80. </view> -->
  81. </view>
  82. <view v-if="!honorList.length" style="text-align: center;">
  83. <image src="/static/nodata.svg" mode="aspectFit" style="width: 300rpx;height: 300rpx;"></image>
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. </template>
  90. <script>
  91. import md5 from "@/common/md5.js";
  92. export default {
  93. data() {
  94. return {
  95. id: "",
  96. details: "",
  97. items:['支部/组织荣誉','我的荣誉'],
  98. current:0,
  99. shareUrl:getApp().globalData.shareUrl,
  100. array:['全部','中央','省级','市级','区级','单位'],
  101. index:0,
  102. indexSelf:0,
  103. dateYear:new Date().getFullYear(),
  104. dateMonth:new Date().getMonth() + 1,
  105. dateYearSelf:new Date().getFullYear(),
  106. dateMonthSelf:new Date().getMonth() + 1,
  107. arraySelf:['全部','中央','省级','市级','区级','单位'],
  108. arrayMonth:["1", "2","3", "4","5", "6","7", "8","9", "10","11", "12"],
  109. imageList: [],
  110. time: "",
  111. globalUrl:getApp().globalData.shareUrl,
  112. honorList:[],
  113. myHonorList:[]
  114. };
  115. },
  116. onLoad() {
  117. this.getHonorList(this.dateYear,this.dateMonth,this.index)
  118. },
  119. methods: {
  120. onClickItem(e){
  121. this.current = e.currentIndex
  122. this.current ?
  123. this.getMyHonor(this.dateYearSelf,this.dateMonthSelf) :
  124. this.getHonorList(this.dateYear,this.dateMonth,this.index)
  125. },
  126. bindDateChange(e){
  127. this.dateYear = e.target.value;
  128. this.getHonorList(this.dateYear,this.dateMonth,this.index)
  129. },
  130. bindDateMonthChange(e){
  131. this.dateMonth = this.arrayMonth[e.target.value];
  132. this.getHonorList(this.dateYear,this.dateMonth,this.index)
  133. },
  134. bindPickerChange(e){
  135. this.index = e.detail.value
  136. this.getHonorList(this.dateYear,this.dateMonth,e.detail.value)
  137. },
  138. bindDateChangeSelf(e){
  139. this.dateYearSelf = e.target.value;
  140. this.getMyHonor(this.dateYearSelf,this.dateMonthSelf,this.indexSelf)
  141. },
  142. bindDateMonthChangeSelf(e){
  143. this.dateMonthSelf = this.arrayMonth[e.target.value];
  144. this.getMyHonor(this.dateYearSelf,this.dateMonthSelf,this.indexSelf)
  145. },
  146. // bindPickerChangeSelf(e){
  147. // this.indexSelf = e.detail.value
  148. // this.getMyHonor(this.dateYearSelf,this.dateMonthSelf,e.detail.value)
  149. // },
  150. goRecord(){
  151. uni.navigateTo({
  152. url:'./record'
  153. })
  154. },
  155. showLarge(src) {
  156. uni.previewImage({
  157. urls: [src],
  158. longPressActions: {
  159. itemList: ["发送给朋友", "保存图片"],
  160. success: function (data) {},
  161. fail: function (err) {
  162. console.log(err.errMsg);
  163. },
  164. },
  165. });
  166. },
  167. getHonorList(y,m,level) {
  168. let md5Sign = md5(
  169. "method=" +"glory" + "&timestamp=" + getApp().globalData.globalTimestamp +
  170. "&secret=" + getApp().globalData.secret
  171. );
  172. let url = getApp().globalData.shareUrl +"api/api.php" +
  173. "?method=glory&action=list&timestamp=" +
  174. getApp().globalData.globalTimestamp +
  175. "&sign=" +
  176. md5Sign;
  177. uni.request({
  178. url: url,
  179. method: "POST",
  180. header: {
  181. "content-type": "application/x-www-form-urlencoded",
  182. },
  183. data: {
  184. openid: getApp().globalData.open_id,
  185. year:y,
  186. month:m,
  187. level:level,
  188. page:1,
  189. page_size:10
  190. },
  191. success: (res) => {
  192. if (res.data.code === 200) {
  193. let list = res.data.data.list;
  194. list.forEach((item)=>{
  195. item.pic_url = this.shareUrl + item.pic_url;
  196. item.pic_url_resize = this.shareUrl + item.pic_url_resize;
  197. })
  198. this.honorList = list;
  199. }
  200. },
  201. fail: () => {
  202. console.log("连接失败");
  203. },
  204. });
  205. },
  206. getMyHonor(y,m) {
  207. let md5Sign = md5(
  208. "method=" +"glory" + "&timestamp=" + getApp().globalData.globalTimestamp +
  209. "&secret=" + getApp().globalData.secret
  210. );
  211. let url = getApp().globalData.shareUrl +"api/api.php" +
  212. "?method=glory&action=my_list&timestamp=" +
  213. getApp().globalData.globalTimestamp +
  214. "&sign=" +
  215. md5Sign;
  216. uni.request({
  217. url: url,
  218. method: "POST",
  219. header: {
  220. "content-type": "application/x-www-form-urlencoded",
  221. },
  222. data: {
  223. openid: getApp().globalData.open_id,
  224. year:y,
  225. month:m,
  226. // level:level,
  227. page:1,
  228. page_size:10
  229. },
  230. success: (res) => {
  231. if (res.data.code === 200) {
  232. let list = res.data.data.list;
  233. list.forEach((item)=>{
  234. item.pic_url = this.shareUrl + item.pic_url;
  235. item.pic_url_resize = this.shareUrl + item.pic_url_resize;
  236. })
  237. this.myHonorList = list;
  238. }
  239. },
  240. fail: () => {
  241. console.log("连接失败");
  242. },
  243. });
  244. },
  245. },
  246. };
  247. </script>
  248. <style lang="scss" scoped>
  249. .content {
  250. .active-title-box {
  251. display: flex;
  252. align-items: center;
  253. margin-top: 10rpx;
  254. font-size: 26rpx;
  255. height: 100rpx;
  256. border-bottom: 1px solid #d7d7d7;
  257. margin-top: 10rpx;
  258. .time-select-box {
  259. width: 32%;
  260. margin-left: 5%;
  261. }
  262. picker {
  263. width: 20%;
  264. border: 1px solid #d7d7d7;
  265. height: 60rpx;
  266. line-height: 60rpx;
  267. border-radius: 10rpx;
  268. margin-left: 20rpx;
  269. padding: 0 10rpx;
  270. position: relative;
  271. image {
  272. width: 20rpx;
  273. height: 20rpx;
  274. position: absolute;
  275. top: 11px;
  276. right: 5px;
  277. }
  278. }
  279. button {
  280. width: 25%;
  281. font-size: 25rpx;
  282. background: #4988fd;
  283. color: #fff;
  284. margin-left: 20rpx;
  285. margin-right: 20rpx;
  286. }
  287. }
  288. .honor-box {
  289. display: flex;
  290. flex-direction: column;
  291. padding: 20rpx 40rpx 20rpx 40rpx;
  292. border-bottom: 1px solid #d7d7d7;
  293. image {
  294. width: 360rpx;
  295. height: 160rpx;
  296. margin: 20rpx auto;
  297. }
  298. .honor-award {
  299. color: #ccc;
  300. font-size: 28rpx;
  301. margin: 20rpx 0 10rpx 0;
  302. }
  303. .honor-info-box {
  304. display: flex;
  305. align-items: center;
  306. font-size: 26rpx;
  307. color: #ccc;
  308. text {
  309. margin-right: 20rpx;
  310. }
  311. }
  312. .edit-icon-box {
  313. position: absolute;
  314. right: 10px;
  315. top: 10px;
  316. image {
  317. width: 35rpx;
  318. height: 35rpx;
  319. margin-right: 10rpx;
  320. }
  321. }
  322. }
  323. }
  324. </style>